Skip to content

Router pauses execution of template when called through notification onclick handler #12624

@marcovdb

Description

@marcovdb

I am having the weirdest issue... I hope the title makes sense. Allow me to elaborate further :)

I'm submitting a ... (check one with "x")

[*] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior
I am using the Notification API to send notifications to my users. I have created a notify service to wrap this functionality that takes care of everything. When the notifications are clicked, I want them to visit a certain part of my app. To accomplish that I use the onclick handler of the notification. I feed it a URL and I call router.navigate in my notify service.

This works, but I am encountering very strange behavior. In the page that is navigated to, I am getting and displaying data from an API, but for some reason execution seems to be halted while the notification is displayed, but only when I navigate using the router. I've experimented with just changing window.location.hash (since I currently use hash-based routing in my app) instead of using the router and then I don't have any problems.

I was able to replicate the problem in a Plunkr, so you can see for yourself.

Expected behavior

Minimal reproduction of the problem with instructions
http://plnkr.co/edit/hr1nB45cTUouXK39E8rE?p=preview

  1. Allow notifications
  2. Click the notification that appears when component 1 is accessed
  3. Observe that the *ngFor isn't executed until the notification is closed programmatically
  4. Navigate between the components manually and see the difference

What is the motivation / use case for changing the behavior?

Please tell us about your environment:
Windows 8.1, VS Code

  • Angular version: 2.1.2

  • Browser: Reproduced in Chrome, Safari and Edge, but in Edge the *ngFor loop doesn't get executed even after the notification disappears.

  • Language: TypeScript

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions