Router: RC6 loadChildren callback causes RangeError: Maximum call stack size exceeded
See original GitHub issueI’m submitting a … (check one with “x”)
[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
App loads main module but then throws RangeError: Maximum call stack size exceeded
exception when it tries to load another module on the route.
RangeError: Maximum call stack size exceeded
at MergeMapSubscriber._tryNext (mergeMap.ts:120)
at MergeMapSubscriber._next (mergeMap.ts:108)
at MergeMapSubscriber.Subscriber.next (Subscriber.ts:95)
at ScalarObservable._subscribe (ScalarObservable.ts:51)
at ScalarObservable.Observable.subscribe (Observable.ts:95)
at Observable._subscribe (Observable.ts:155)
at MergeMapOperator.call (mergeMap.ts:82)
at Observable.subscribe (Observable.ts:93)
at Observable._subscribe (Observable.ts:155)
at MergeMapOperator.call (mergeMap.ts:82)
const routes: Routes = [
{
path: "",
component: "ChildComponent",
loadChildren: () => ChildModule
}
];
The same happens if I set the new “initialNavigation” option on the route options to false and with a delayed call to router.initialNavigation();
Expected/desired behavior The child module should load and the component rendered
Reproduction of the problem If the current behavior is a bug or you can illustrate your feature request better with an example, please provide the steps to reproduce and if possible a minimal demo of the problem via https://plnkr.co or similar (you can use this template as a starting point: http://plnkr.co/edit/tpl:AvJOMERrnz94ekVua0u5).
I’ve made a Plunker here: https://plnkr.co/edit/au7M3UG1eP6hUpETs1D4?p=preview
What is the expected behavior?
N/A
What is the motivation / use case for changing the behavior?
N/A
Please tell us about your environment:
- Angular version: 2.0.0-rc.6
- Browser: Chrome 52.0.2743.116 m
- Language: TypeScript 1.8.6
Issue Analytics
- State:
- Created 7 years ago
- Reactions:2
- Comments:11 (3 by maintainers)
In my case it was because I wasn’t importing the routing module (where the paths were defined) to my feature module.
I fixed it by adding routing to my ChildModule. for example a route {path:‘’,component:ChildComponent}
Also you will want to get rid of the reference to ChildComponent in app.ts