Angular cli generate module

preview_player
Показать описание
In this video we will discuss generating modules using the Angular CLI.

Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.

To generate a module use
ng generate module moduleName or ng g m moduleName

For example. to generate a students module we could use
ng generate module students -d or ng g m students -d

Please note : Since we are using the --dry-run flag, the module file and folder is not actually created. We only get the report of the files and folders that will be created.

The above command generates the students module inside students folder. Remember for us to be able to use this newly 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

The following command not only generates students module, it also imports it into the root module (AppModule)

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

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.

Unitil now, we have been using the --dry-run option. Now let's remove the -d option and execute the command so the module is actually created.

1. The required import statement to import students module is included
2. The students module is also included in the "imports" array

Text version of the video

Slides

Angular CLI Tutorial

Angular CLI Text articles & Slides

All Dot Net and SQL Server Tutorials in English

All Dot Net and SQL Server Tutorials in Arabic
Рекомендации по теме
Комментарии
Автор

Hi Venkat, Thank you for your videos, it helps me a lot...
I having problem in angular material setup, please can you make the videos which is related to angular material and how to work using angular material....

lanka
Автор

Great tutorial. Please provide tutorials for React JS also

manishnarang
Автор

is that enough --flat or we have to mention --flat =true to get without folder?

soumyajohn
Автор

sir, how to install boostrap and get intelisence?.

susanthaperera
Автор

Hey Venkat
is there angular/cli command to remove/Delete project, component, service ...

ruthyayele
Автор

Thank you so much! It helped me a lot. :)

fullStackInKannada
Автор

I think you are already doing angular4, am i correct sir ?

susanthaperera
Автор

hi sir
--module=app.module not working in ubendu...please help me

SS-tjlt
Автор

Is there an option to not have the app.module modified? We use a different method of registration and would like to skip this step. Thanks for the video!

ryanconnollyatwork
Автор

ng g m students -d -m=app.module --spec=true
unknown Option:'--spec'

adilkevin