Angular2 RC1 child routes defined but not recognized Angular2 RC1 child routes defined but not recognized angular angular

Angular2 RC1 child routes defined but not recognized


Note that the path can only be 'heroes'. if I change to [routerLink] and @Routes to '/heroes' it won't work. Can some help explain why?

Actually paths in child router can contain "/" as prefix but changing routerLink to "/heroes" made it not work because "/" prefix in navigation path will be resolved using root router and does not have "/heroes" path. "heroes" path worked because it will be resolved using current router and you defined that path in current child router.

this._router.navigate(['hero/'+hero._id]);

Calling "navigate" without a segment will be resolved using root router. It means you want to do absolute navigation. Obviously this will not work.

this._router.navigate(['hero/'+hero._id],this.currSegment);

This also did not work because you are at HeroesComponent and "heroes" segment, there is no router configuration in the component. The correct call should be:

this._router.navigate(['../hero', {_id: hero._id}], this.currSegment);