I've tried the sample on the official page but neither it works nor the other examples on other pages work me. There are no params neither of the router nor the route export. How can I subscribe and get the parameter change? Neither can I use the RouteParams, I got an exception there is no provider for it. Thank you!
How am I able to do this with the current version of angular 2?
private sub: any;
ngOnInit() {
this.sub = this.route.params.subscribe(params => {
let id = +params['id']; // (+) converts string 'id' to a number
this.service.getHero(id).then(hero => this.hero = hero);
});
}
my code:
@RouteConfig([
{ path: '/:appleId/:bananaId/fruits/...', name: 'Fruits', component: FruitsComponent }
])
How Can I get the appleId or bananaId change in the FruitsComponent?
The this.route.params
does not exist :( What should I use instead?