user2180794 user2180794 - 1 year ago 208
Node.js Question

Angular2 Notifications chaining with router navigate

I have a simple application form which on submit navigates to another page.
I want to display a success message on clicking the submit button.

The below code works but after submit, it immeidately redirects to other page which shows the notifications for only a second.
I cannot add the notificaiton to the destination page as it has multiple entry points.

onSubmit(form) {
this._service.success('Test', 'Test'); // this is from angular2-notificaitons library
this.apartmentService.postRequests(>this.router.navigate(['Requests'])); //navigates to requests page which has multiple entry points = {};

Any idea how to achieve this ?


Where did you register the provider for the NotificationsService. I think the problem is that you're not registering it at the root of the application.

Try to move the NotificationsService and the SimpleNotificationsComponent directive to your app.component.

        selector: "app",
        directives: [SimpleNotificationsComponent],
        providers: [NotificationsService, PushNotificationsService],
        template: `
           <simple-notifications [options]="options" (onCreate)="onCreate($event)" (onDestroy)="onDestroy($event)">