简体   繁体   中英

Angular 2: Passing Async Data to Routes?

I have routing with child and I need to pass date which parent get from http request to child route. I tried to use service to sharing data but i want only want only one request.

It's my routes:

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

My second question is how to handle route with optional parameters (without reloading component)

http://example.com/route 

same as

http://example.com/route/param

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM