我想动态获取或设置页面的标题。我发现this但我不知道如何使用它。
答案 0 :(得分:1)
你可以这样做:
export class AppComponent {
public constructor(private titleService: Title ) { }
public setTitle( newTitle: string) {
this.titleService.setTitle( newTitle );
}
}
答案 1 :(得分:1)
这很简单。在要操作标题的组件中,添加以下内容:
<强> component.ts
constructor(private documentTitle: Title) {
documentTitle.setTitle('Whatever title you want');
}