DEV Community

Generate component with inline template and style using Angular CLI

Sumit Kharche on January 05, 2020

Whenever we want to create a new component using Angular CLI what we usually do is by running below command: > ng generate component <comp...
Collapse
 
evansaa1 profile image
Ashley Evans

Good write-up Sumit, I was using this approach for a while but I'm lazy so I started using the shorthand version of the options, -t=true -s=true, but that's still too much typing so I updated the defaults in my angular.json file.

"schematics": {
"@schematics/angular:component": {
"style": "scss",
"inlineTemplate": true,
"inlineStyle": true
}
},

Now when I run the following the component is generated in a single file with no additional components.

ng g c <component-name>

Collapse
 
ahmedkhairydev profile image
Ahmed Khairy

In Angular V.14, you should replace inlineTemplate with inline-template and inlineStyle with inline-styleto work with you and don't get this error:
Error: Unknown arguments: inlineTemplate, inlineStyle`. Thanks.