app.component.html
テンプレートにルートの名前を表示したいとします。角2、現在のルート名を表示する方法は? (ルータ3.0.0-beta.1)
{{router.currentRoute.name}}
私の現在のルータの設定:あなたのルートは、データプロパティに自分のルート名で構成されている場合
export const routes: RouterConfig = [
{
path: '',
redirectTo: '/catalog',
pathMatch: 'full'
},
{
path: 'catalog',
name: 'Catalog', // Is this property deprecated?
component: CatalogComponent
},
{
path: 'summary',
name: 'Summary',
component: SummaryComponent
}
];
新しいルータにルート名はありません。 –
ルート名を表示する場合は、私自身のソリューションをコーディングする必要がありますか? –
これに 'data'パラメータを使うことができます。 https://angular.io/docs/ts/latest/api/router/index/RouterConfig-type-alias.html –