I have a dashboard application which consists of a treeview component (which lists various content nodes) and a dashboard-edit component which renders some editable content
In the new router (>= RC.0 <=RC.2) this would be
import 'rxjs/add/operator/first';
...
constructor(private router:Router, private routeSerializer:RouterUrlSerializer, private location:Location) {
router.changes.first().subscribe(() => {
let urlTree = this.routeSerializer.parse(location.path());
console.log('id', urlTree.children(urlTree.children(urlTree.root)[0])[0].segment);
});
}
See also Angular 2 RC1: Get parameters from the initial URL used