Skip to content

Add ability to configure default changeDetection and viewEncapsulation used by component generator #2822

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
jschwarty opened this issue Oct 21, 2016 · 1 comment
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent

Comments

@jschwarty
Copy link
Contributor

jschwarty commented Oct 21, 2016

Overview of the Requested Feature

Would like to have a way to set the global behavior of the component generator to handle writing the following component metadata properties:

  • changeDetection
  • viewEncapsulation

Something like the ability to set the default values to use for these from within the angular-cli.json file (or maybe some other generators config file) like so:

{

  . . .

  "defaults": {
    "changeDetection": "OnPush",
    "viewEncapsulation": "Native",
    . . .
  }
}

with the following potential string values:

  • "OnPush" or "Default" for changeDetection
  • "Emulated", "Native" or "None" for viewEncapsulation

If these properties are not in the angular-cli.json file then the metadata properties would not be included in the component generator template (same behavior it currently does).

Change Detection

If `"changeDetection" is set, the component metadata property would be included and set in the component generator template like so:

@Component({
  . . .
 changeDetection: ChangeDetectionStrategy.OnPush,
  . . .
})

with "OnPush" using ChangeDetectionStrategy.OnPush and "Default" using ChangeDetectionStrategy.Default.

View Encapsulation

If `"viewEncapsulation" is set, the component metadata property would be included and set in the component generator template like so:

@Component({
  . . .
 viewEncapsulation: ViewEncapsulation.Native,
  . . .
})

with "Native" using ViewEncapsulation.Native, "Emulated" using ViewEncapsulation.Emulated and "None" using ViewEncapsulation.None.

Note

I think the ideal solution would be to have a way to create custom generator templates at a project level so users could control more than just the component metadata, but I am not sure if that is on the radar and if so, how far out it is.

@Brocco Brocco self-assigned this Oct 25, 2016
Brocco added a commit to Brocco/angular-cli that referenced this issue Oct 26, 2016
Brocco added a commit to Brocco/angular-cli that referenced this issue Oct 26, 2016
Brocco added a commit to Brocco/angular-cli that referenced this issue Oct 26, 2016
@filipesilva filipesilva added type: enhancement P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent labels Oct 27, 2016
MRHarrison pushed a commit to MRHarrison/angular-cli that referenced this issue Feb 9, 2017
@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
P3 An issue that is relevant to core functions, but does not impede progress. Important, but not urgent
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants