在angular2中如何导入路由器段,以便我可以使用getParam函数
我正在使用最新的angular2库
目前的ts代码:
import {Component} from '@angular/core';
import {Router, ActivatedRoute} from '@angular/router';
@Component({
moduleId: module.id,
selector: 'BlogArticleComponent',
templateUrl: 'blogArticle.component.html'
})
export class BlogArticleComponent {
router : Router;
jobSlug: string;
constructor(router: Router, route: ActivatedRoute){
this.router = _router;
this.jobSlug: = route.params.map(p => p.slug);
console.log(this.jobSlug);//undefined currently
}
这是我需要开始工作的代码:
this.jobSlug:= route.params.map(p => p.slug);