Angular 如何使用角度';标题';应用程序编程接口?

Angular 如何使用角度';标题';应用程序编程接口?,angular,Angular,我想动态获取或设置页面标题。我找到了,但我不知道如何使用它。你可以这样做: export class AppComponent { public constructor(private titleService: Title ) { } public setTitle( newTitle: string) { this.titleService.setTitle( newTitle ); } } 资料来源:这很简单。在要操纵标题的组件中,添加以下内容: 组件。ts con

我想动态获取或设置页面标题。我找到了,但我不知道如何使用它。

你可以这样做:

export class AppComponent {
  public constructor(private titleService: Title ) { }

  public setTitle( newTitle: string) {
    this.titleService.setTitle( newTitle );
  }
}

资料来源:

这很简单。在要操纵标题的组件中,添加以下内容:

组件。ts

constructor(private documentTitle: Title) {
    documentTitle.setTitle('Whatever title you want');
}

你需要表现出至少一些努力,以便有人从一天中抽出时间来帮助你。谷歌首次搜索“角标题服务”。你能这么懒吗?天哪,这怎么能不出现在菜单上呢?谢谢你,伙计,你救了我的命,,