2

Is there any way to provide an access to ContentChildren which are inside ng-template?

If you look at the example you see the issue - the routerLinkActive directive does not see any routerLink directives in the second row.

<div routerLinkActive="active">
  <a routerLink="/hello">Hello</a> | <a routerLink="/blank">Blank</a>
</div>

<div routerLinkActive="active"> <!-- non-working RouterLinkActive -->
  <ng-container *ngTemplateOutlet="menu"></ng-container>
</div>

<router-outlet></router-outlet>

<ng-template #menu>
  <a routerLink="/hello">Hello</a> | <a routerLink="/blank">Blank</a>
</ng-template>

For understanding how the routerLinkActive directive works you can look at the code

constantant
  • 1,192
  • 1
  • 13
  • 25

0 Answers0