-
Notifications
You must be signed in to change notification settings - Fork 11.9k
Closed
Description
Bug Report or Feature Request (mark with an x)
- [X] bug report -> please search issues before submitting
- [ ] feature request
Versions.
clean project using 1.1.3
Repro steps.
Create a function to process some routes, then concat with Route array to use with RouterModule.forRoot();
When first time ng serve runs, compilation fails due to AOT error:
"Cannot read property 'loadChildren' of undefined"
The log given by the failure.
Hash: 65d3fc8e5c37db4aefe7
Time: 9450ms
chunk {0} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 160 kB {4} [initial] [rende
red]
chunk {1} main.bundle.js, main.bundle.js.map (main) 12.5 kB {3} [initial] [rendered]
chunk {2} styles.bundle.js, styles.bundle.js.map (styles) 10.5 kB {4} [initial] [rendered]
chunk {3} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.47 MB [initial] [rendered]
chunk {4} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ERROR in Cannot read property 'loadChildren' of undefined
webpack: Failed to compile.
Desired functionality.
I need to use prepare some of my routes, and I want to make it simple, using a function.
What want to pass to the function:
{path: 'some/path', component: 'SomeCrudComponent', service: 'CrudService'}
Then, it returns me
{path: 'some/path', component: 'OtherComponent', data:{..}, children: [
{path: 'list', component: 'Other1Component', data:{..}},
{path: 'edit/:id', component: 'Other2Component', data:{..}, resolve: {item : CrudService}},
{path: 'new', component: 'Other3Component', data:{..}}
...
]}
And then:
const export appRoutes: Routes = [
{path: 'some/normal/component', component: 'NormalComponent'}
].concat(processRoutesThatNeedIt([
{path: 'some/path', component: 'SomeCrudComponent', service: 'CrudService'}
]))
...
RouterModule.forRoot(appRoutes)
Mention any other details that might be useful.
Sample project error:
https://github.com/wilker7ribeiro/loadChildrenError
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels