As mentioned, I used the ng demo today according to the official statement, but there is one thing I don’t understand.
On the Internet, I saw that some people use ngmodule as a container (for example, the home page is an ngmodule, and the background login page is an ngmodule).
Then organize the page structure, and introduced components and services through this module-level container.
I created a new homemodule (a component is declared in it, and the selector of the component is test1) to organize the content of the homepage, and then imported it in the root module.
Then I wrote <test1></test1> in the bootstrap component of the root component. Why does it tell me that the statement is wrong? Do I have to declare this component in the root component? If the project gets bigger, it will become a mess
某草草2017-05-15 17:15:59
Refer to the NG module section of Angular Chinese documentation.
Module includes the main module AppModule, as well as feature module, etc. When the project is complex, the feature module can be used to place multiple components, instructions, services, etc. with the same characteristics. When using a feature module, you need to export the content in your declarations that needs to be exposed to the main Module. The main module needs to import other feature modules
为情所困2017-05-15 17:15:59
Summary in one sentence:
If you are doing a small project, don’t worry about so many, one root module can solve everything;
If you are doing a medium to large project, it is recommended to divide the modules according to business modules.
大家讲道理2017-05-15 17:15:59
bootstrap only needs to be declared in appModule, and the rest can be used as routing to make feature modules