Thursday, 27 December 2018

How to generate module Angular cli ?

To generate a module use

ng generate module Admin

OR 

ng g m Admin

The above command generates the Admin module inside the Admin folder. To be able to use the generated module, we must import it in the root module.

We can do it manually after creating the module or we can tell Angular CLI to import our newly generated module into the root module using --module option. We can also use it's alias -m

ng g m Admin -m=app.module

By default, a spec file is not generated. If you also want a spec file to be generated use the --spec option

ng g m Admin -m=app.module --spec=true

When generating a module, Angular CLI by default creates a folder for the module and places the module files in that folder. If you do not want a dedicated folder for the module you are generating, use --flat option.

ng g m Admin -m=app.module --spec=true --flat=true

No comments:

Post a Comment