When I was developing angular, I encountered the following errors:
core.js:6242 ERROR NullInjectorError: R3InjectorError(AppModule)[ChildrenOutletContexts -> ChildrenOutletContexts -> ChildrenOutletContexts]:
NullInjectorError: No provider for ChildrenOutletContexts!
at NullInjector.get (core.js:1086)
at R3Injector.get (core.js:16969)
at R3Injector.get (core.js:16969)
at R3Injector.get (core.js:16969)
at NgModuleRef$1.get (core.js:36344)
at Object.get (core.js:33987)
at getOrCreateInjectable (core.js:5849)
at Module. ɵɵ directiveInject (core.js:21118)
at NodeInjectorFactory.RouterOutlet_ Factory [as factory] (router.js:9156)
at getNodeInjectable (core.js:5994)
The reason is found in this stackoverflow discussion post:
This error is because the module generated by routermodule. Forchild() contains necessary instructions and routes, but does not contain routing service – routing provider. This is the purpose of routermodule.forroot: it generates a module containing necessary instructions, routes and routing services.
terms of settlement
Call routermodule.forroot ([]) in app.module.ts
Call routermodule.forchild in feature module to pass in the actual routing array:
More Jerry’s original articles can be found in: “Wang Zixi”:
Read More:
- The difference between “?” and “?:” introduced by php7
- The difference between LSTM and Gru
- The difference and usage of insmod and modprobe
- The difference between problem and observables
- Difference between getelementsbyname and getelementbyid
- JavaScript summary: the difference between typeof and instanceof, and Object.prototype.toString() method
- C#: Analysis of the difference between write() and writeline()
- The difference between classnotfoundexception and NoClassDefFoundError
- The difference between sleep() and wait() in Java
- Node.js Medium package.json The difference between devdependences and dependencies
- The difference between onready or $() and onload
- The difference between hive and relational database
- The difference of. Pt,. PTH,. Pkl and the way to save the model
- The usage and difference of atoi() and stoi() functions in C + +
- Difference between vs code user and system version
- The tutorial and difference of glew, glfw, glad and freeglut
- Python json.dumps () json.dump The difference between ()
- Parsing the difference between “R” and “RB” patterns of text files (Python)
- Difference between isempty method and isblank method in stringutils
- The difference of four kinds of integer function (fix floor ceil round) in MATLAB