Sunday, 3 November 2019

How to generate a new component using angular CLI?


Below are the commands to create a new component
ng generate component abc



You can tell the angular CLI to place a component at a particular folder. If folder is existing then it will place there or else it will create a new folder for you and place the component at there.



If you do not want to create a component in its own folder then you may do this by using below command. In this case component is created under app folder.



If you do not want to create the spec files (used for unit testing), use below command.



In the above it says spec is deprecated and we can use skipTests instead of this.



We can use -d option which stands for dry run. Means it will show you what angular CLI will do for you.



To use sass instead of CSS with your component, use the --style=scss flag with ng generate command. If you want less use --style=less



No comments:

Post a Comment