Angularで各ページのtitleを変更する方法




各ページのcomponent.tsファイルにて、

①Titleクラスをインポート
import { Title } from '@angular/platform-browser';

②コンストラクタにて、TitleをDI(依存性の注入)する。
constructor(private title: Title) {
}

③ngOnInitにてタイトルを設定
ngOnInit() {
this.title.setTitle("タイトル1");
}




シェアする

  • このエントリーをはてなブックマークに追加

フォローする