It’s any way to create component with cli to select the files of generate component? Or it can only set in the template in editors.
Sometimes, I need to create a simple component and i want to create a standalone component with one ts file,
However, when i use ng g c --standalone AComponent, It will create html, scss, spec, ts four file;
>Solution :
In the angular.json, we can also configure it in @schematics/angular:component.
...
"schematics": {
"@schematics/angular:component": {
"prefix": "app",
"style": "scss",
"skipTests": true,
"inlineStyle": true,
"inlineTemplate": true,
},
...
We can also use the arguments to control this.
ng g c test -s -t --skip-tests
ng generate component
–inline-style
Alias: s
Include styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the > component.ts file.
Value Type: boolean
Default: false
–inline-template
Alias: t
Include template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.
Value Type: boolean
Default: false
–skip-selector
Specifies if the component should have a selector or not.
Value Type: boolean
Default: false
–skip-tests
Do not create "spec.ts" test files for the new component.
Value Type: boolean
Default: false