Open prabh-62 opened 3 years ago
Reopening cause I got confused with another option
At the moment this is working as expected since the application schematic doesn’t have the ChangeDetection
Let’s leave this open for the time being and see if there is a strong enough interest from the community to add this feature.
My 2 cents is that this is too trivial to add manually (which also happens to be rare) and hence it doesn’t warrant an API change in the application schematic.
@alan-agius4 @mgechev maybe it's will be improved for https://angular.io/guide/strict-mode ?
@splincode, enabling onPush by default is not something that we want to do for a number of reasons, also OnPush doesn’t fit in the strict mode scope as this changes the runtime behaviour.
See https://github.com/angular/angular-cli/issues/21278 and https://github.com/angular/angular-cli/issues/17589#issuecomment-639402075
@prabh-62 I strongly agree with @alan-agius4 that we should NOT have onPush by default. It should be opt in. Because new joiners to Angular dont know about onPush strategy and how it works. It can be very overhelming to them. If you want to auto generate components with onPush on your custom project use this in angular.json
"projects": {
"yourProjectName": {
"projectType": "application",
"schematics": {
"@schematics/angular:component": {
"style": "scss",
"changeDetection": "OnPush"
}
},
🐞 Bug report
Command (mark with an
x
)Is this a regression?
N/A
Description
One should be able to generate angular application with
changeDetection.OnPush
components.🔬 Minimal Reproduction
npx @angular/cli@12 new web-apps --create-application false
cd web-apps
yarn ng config schematics.@schematics/angular:component.changeDetection OnPush
yarn ng generate application admin-dashboard --prefix ad --routing --style css
projects/admin-dashboard/src/app/app.component.ts
and there is no changeDetection set.🔥 Exception or Error
🌍 Your Environment
Anything else relevant?
yarn ng generate component components/home --project admin-dashboard
andchangeDetection
is set toonPush
for generatedprojects/admin-dashboard/src/app/components/home/home.component.ts