相关疑难解决方法(0)

如何在包含 RouterOutlet 的 HTML 模板中直接使用激活路由的数据?

这个我花了一段时间才弄明白,所以我希望通过在 SO 的问答方式中分享解决方案来节省某人的时间。它是这样的:

目标

我有一个 Angular8 Web 应用程序,我使用RouterModule在组件之间导航。

以下是我的路线的定义方式:

const routes: Routes = [
    { path: 'moo', component: AppMooComponent, data: { title: 'Moo Section', desc: 'Moo is the first example component.' } },
    { path: 'boo', component: AppBooComponent, data: { title: 'Boo Section', desc: 'Boo is the second example component.' } },
    { path: 'foo', component: AppFooComponent, data: { title: 'Foo Section', desc: 'Foo is the third example component.' } },
    { path: '', redirectTo: 'moo', pathMatch: 'full' …
Run Code Online (Sandbox Code Playgroud)

angular2-routing angular angular8

7
推荐指数
1
解决办法
1497
查看次数

标签 统计

angular ×1

angular2-routing ×1

angular8 ×1