Browse Source
Merge pull request #4543 from abpframework/fix/4542
Used Legacy Router Config w/ Children Based on Router Data
pull/4546/head
Mehmet Erim
6 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
4 additions and
4 deletions
-
npm/ng-packs/packages/core/src/lib/handlers/routes.handler.ts
|
|
|
@ -20,7 +20,7 @@ export class RoutesHandler { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
const routes = flatRoutes([{ ...data.routes, path }], { path: '' }); |
|
|
|
const routes = flatRoutes([{ path, ...data.routes }], { path: '' }); |
|
|
|
this.routes.add(routes); |
|
|
|
}); |
|
|
|
} |
|
|
|
@ -30,13 +30,13 @@ function flatRoutes(routes: RouteDef[], parent: any) { |
|
|
|
if (!routes) return []; |
|
|
|
|
|
|
|
return routes.reduce((acc, route) => { |
|
|
|
const current = { |
|
|
|
const { children, ...current } = { |
|
|
|
...route, |
|
|
|
parentName: parent.name, |
|
|
|
path: parent.path + '/' + route.path, |
|
|
|
path: (parent.path + '/' + route.path).replace(/\/\//g, '/'), |
|
|
|
}; |
|
|
|
|
|
|
|
acc.push(current, ...flatRoutes(current.children, current)); |
|
|
|
acc.push(current, ...flatRoutes(children, current)); |
|
|
|
|
|
|
|
return acc; |
|
|
|
}, []); |
|
|
|
|