假设我使用以下表达式为路由器中的角度组件设置页面标题:
{path:'view-move /:moveName',component:ViewMoveComponent,data:{title:'View Move'}}
假设我使用路由器参数来获取移动详细信息,包括他的名字,我如何将移动名称放在我的标题中,所以它就像:
查看移动:移动名称
更新:我试过:
import { BrowserModule, Title } from '@angular/platform-browser';
constructor(public http: Http,private route: ActivatedRoute,private titleService: Title) {
this.titleService.setTitle("My Title");
}
现在没有标题
答案 0 :(得分:0)
您需要将TitleService
注入您的组件并使用其setTitle
方法。
https://angular.io/docs/ts/latest/cookbook/set-document-title.html