【问题标题】:Angular 2: Passing Async Data to Routes?Angular 2:将异步数据传递给路由?
【发布时间】:2017-02-28 16:23:31
【问题描述】:

我有子路由,我需要将父节点从 http 请求中获取的日期传递给子路由。我尝试使用服务来共享数据,但我只想要一个请求。

这是我的路线:

const routes: Routes = [
    {
        path: 'page/:category',
        component: PageComponent,
        children: [
            {
                path: ''
            },
            {
                path: '/:id',
                component: PageDetailComponent
            }
        ]
    }
];

我的第二个问题是如何处理带有可选参数的路由(无需重新加载组件)

http://example.com/route 

一样
http://example.com/route/param

【问题讨论】:

标签: angular angular2-routing


【解决方案1】:

解决方案是路由数据解析,因为子路由可以访问其父数据。

【讨论】:

    猜你喜欢
    • 2016-09-06
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-01-23
    • 2022-01-13
    相关资源
    最近更新 更多