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.
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:
Something like the ability to set the default values to use for these from within the
angular-cli.jsonfile (or maybe some other generators config file) like so:with the following potential string values:
If these properties are not in the
angular-cli.jsonfile 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:
with "OnPush" using
ChangeDetectionStrategy.OnPushand "Default" usingChangeDetectionStrategy.Default.View Encapsulation
If `"viewEncapsulation" is set, the component metadata property would be included and set in the component generator template like so:
with "Native" using
ViewEncapsulation.Native, "Emulated" usingViewEncapsulation.Emulatedand "None" usingViewEncapsulation.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.