4
假設我使用以下表達式來設置角度成分頁面標題在我的路由器:角2路由器標題與參數
{路徑:「視圖-移動/:moveName」,組分:ViewMoveComponent,數據:{標題:「查看移動」}}
假設我用的路由器PARAMS獲得移動細節,包括他的名字,我怎麼可以把移動名字我的標題裏面,所以它會像:
查看移動:移動名稱
更新:我想:
import { BrowserModule, Title } from '@angular/platform-browser';
constructor(public http: Http,private route: ActivatedRoute,private titleService: Title) {
this.titleService.setTitle("My Title");
}
沒有標題現在
'進口{BrowserModule,標題}從 '@角/平臺的瀏覽器'; 構造函數(公共http:Http,私人路由:ActivatedRoute,私人titleService:標題){ this.titleService.setTitle(「My Title」); }'不設置任何標題 – TheUnreal
您必須將服務添加到應用程序模塊中的providers數組中 –