Wednesday, 28 February 2018

Frequently used Angular cli Commands angular


Following are the mostly used angular-cli commands which are working with angular2 and greater version


How to create Module with rouring files / route.ts 

=> ng g module user --routing

=>Example :

   ng g module user --routing
 
NOTE : this will add the module inside app like app/user/user.route.ts , its best practice to use lazy routing for angular ,and for this you need to make modular routing

How to create a component inside specific module

=> ng g component moduleName/newComponent

=> Example : if you to module 'user' and on this component you need to create module then do ,

          ng g component user/create-user
          ng g component user/delete-user

NOTE : after this hit , the component automatically import in the respected module you don't need to define again

How to create a module inside another module 


in some cases we need to use nested module structure for angular app.for this generally people make use of ../cd :-) 
but that's not correct way use following command :

==> ng g module moduleA/moduleB --routing

==> Example : 
        
       ng g module user/adminUser --routing

In above example we will create a module adminUser inside module user

NOTE : always remember PARENT-MODULE/NEW-MODULE, left side is a parent module and right side is a newly creates module inside parent module

No comments:

Post a Comment