Search code examples
angularangular2-routingangular2-router3

RouterLink don't adds href at first load from parent page template


I have root page with child pages, root page template has [routerLink] directives that route to child pages. Something like this:

<a [routerLink]="['/home', 'auidiences']"></a>
<router-outlet></router-outlet>

HomeComponуnt has ROUTER_DIRECTIVES in directives section.*

When I navigate to page at first time links don't have hrefs, but if I update page they do and work. Any idias?


Solution

  • The reason is as I understand related to this bug. And one more - user answer. OnInit doesn't fire and there is no component that works fine after router navigation.

    To solve this problem you need to wrap your navigation call into zone.run().