Routing in Angular 2

You may already know how to create routes using the CouterConfig class, I suppose. So maybe you also have a route like this one:

{ path: 'theme/:themeId', component: ThemeComponent },

The question for me was then: How to get the :themeId inside the ThemeComponent.

The solution is to inject the ActivatedRoute into the component containing all information you need ;-)

import {ActivatedRoute} from '@angular/router';
export class ThemeComponent implements OnInit {
private themeId: string;

constructor(private route: ActivatedRoute) {
}

ngOnInit() {
this.route.params.subscribe((parameter: any) => {
this.themeId = parameter.themeId;
});
}

}

(I was a little bit lazy not implementing a class for the subscribe function.)

Missing something, need more info/help?