2

I am using Angular2 RC3 and the new router. My HTML ...

<nav>
  <a [routerLink]="['/route1']" [routerLinkActive]="['active']">Route 1</a>
  <a [routerLink]="['/route2']" [routerLinkActive]="['active']">Route 2</a>
</nav>

routerLinkActive applies the 'active' class according to the selected link. Works great.

Problem is by adding [routerLinkActive] my unit tests now fail with ...

undefined is not an object (evaluating 'router.events.subscribe')

anyone got a fix for this?

many thanks

danday74
  • 52,471
  • 49
  • 232
  • 283
  • Hard to tell. It's not caused by the routerLinks above. Please show more code or try to reproduce in https://angular.io/resources/live-examples/quickstart/ts/plnkr.html – Günter Zöchbauer Jun 30 '16 at 04:18
  • if i remove [routerLinkActive]="['active']" everything works fine – danday74 Jun 30 '16 at 04:27
  • That might be. Because the `routerLink` directive injects the router and probably other things and when the router is not properly initialized or something else causes problems, this fails. – Günter Zöchbauer Jun 30 '16 at 04:30

1 Answers1

0

i put the tests on 'skip' in the end using Jasmine's xit

This is no longer a problem on ng2 final release

danday74
  • 52,471
  • 49
  • 232
  • 283