angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

There is no a command that can set detection strategy to OnPush by default with `ng new`

Open RayKimEX opened this issue 7 years ago β€’ 4 comments

πŸš€ Feature request

Command (mark with an x)

- [ x ] new
- [ ] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [ ] config
- [ ] help
- [ ] version
- [ ] doc

Description

There is no a command that can set detection strategy to OnPush by default with ng new

Describe the solution you'd like

Add a additional parameters like --style=scss that can set detection strategy to OnPush by default with 'ng new' in CLI

Describe alternatives you've considered

There is Alternatives. ng config schematics.@schematics/angular.component.changeDetection OnPush

But I want to set detection strategy with ng new like --style=scss I think this is worthy

Thank you for reading

RayKimEX avatar Aug 27 '19 02:08 RayKimEX

Duplicate of https://github.com/angular/angular-cli/issues/13327

alan-agius4 avatar Aug 27 '19 04:08 alan-agius4

Duplicate of #13327

@alan-agius4 Thank you for comment. However you said in #13327 that ng new creates only single component, and it would be trivial to change the change detection for the root compoenent

But what i want is including ng config feature.

When you create with ng new with --style=scss Then it sets

        "@schematics/angular:component": {
          "styleext": "scss",

          // this is what i want feature with 'ng new' command and parameter
          "changeDetection" : "OnPush"
        },

If you don't mind, could you explain for me why ng new with--style=scss is accepted, but ng new with changeDetection='OnPush' can not be accepted?

I think this would not be trivial. Because when you create using ng generate. it sets change detection strategy to OnPush in ng-generated.component.ts file by default

RayKimEX avatar Aug 27 '19 05:08 RayKimEX

The style option controls more than just a single component style. The option is used to generate the global style sheet extension and configures the styles option under the browser and test builder.

ng new only exposes a subset of options from the component schematic. Ex viewEncapsulation, selector, skipSelector and other as not exposed.

If you want to use ng generate component and always set the changeDetection to OnPush you will need to run the above mentioned command after ng new. (Note: it won't update existing components)

alan-agius4 avatar Aug 27 '19 09:08 alan-agius4

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.