From blog post protecting routes using guards in angular we can pop a message when a user cannot access a route. :
import { CanDeactivate } from '@angular/router';
import { CanDeactivateComponent } from './app/can-deactivate';
export class ConfirmDeactivateGuard implements CanDeactivate<CanDeactivateComponent> {
canDeactivate(target: CanDeactivateComponent) {
if(target.hasChanges()){
return window.confirm('Do you really want to cancel?');
}
return true;
}
}
I would like to show a modal dialog using ngx-bootstrap to allow the user to login.
I have managed to get some simple code loading the modal from the main app (eg not a child view from my app.component.ts
), such as
showloginModal() {
this.loginModal.show();
}
the modal is loaded from another HTML file with (I include the core login code with the selector app-login
<div class="modal-body">
<app-login #loginModal> </app-login>
</div>
edit I have just had a look at Angular2 DialogService – Exploring Bootstrap and that looks like it does the job but it's for bootstrap4