In the old angular cli there was a key called defaults
:
"defaults": {
"schematics": {
"collection": "@nrwl/schematics",
"postGenerate": "npm run format",
"newProject": [
"app",
"lib"
]
},
"styleExt": "scss",
"component": {
"changeDetection": "OnPush"
}
}
This property no longer exsists. How do I add component/changeDetection on push in angular cli 6+? moreover is there a list of component properties I can add?
Creating a component using the Angular CLIlink Run the ng generate component <component-name> command, where <component-name> is the name of your new component.
component. spec. ts: This file is a unit testing file related to app component. This file is used along with other unit tests. It is run from Angular CLI by the command ng test.
I'm not as familiar with the old CLI. Were those properties configured as global CLI settings, or a per-project setting?
In the new Angular CLI, you can replicate per-project settings in the angular.json
file by updating the schematics
object to the following:
"projects": {
"my-project": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {
"@schematics/angular:component": {
"changeDetection": "OnPush"
}
},
Via the Angular CLI, you can do it as follows:
ng config schematics.@schematics/angular:component.changeDetection OnPush
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With