Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { Component, OnInit } from '@angular/core';
import {<% if(changeDetection === 'OnPush') { %> ChangeDetectionStrategy,<%} %> Component, OnInit } from '@angular/core';

@Component({
selector: '<%= selector %>',
templateUrl: './<%= dasherize(name) %>.<%= dasherize(type) %>.html',
styleUrls: ['./<%= dasherize(name) %>.<%= dasherize(type) %>.<%= styleext %>'],<% if(standalone) {%>
standalone: true,<%} %>
standalone: true,<%} %><% if(changeDetection === 'OnPush') { %>
changeDetection: ChangeDetectionStrategy.OnPush,<%} %>
})
export class <%= classify(name) %><%= classify(type) %> implements OnInit {

Expand Down
1 change: 1 addition & 0 deletions packages/schematics/component/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ export interface Schema {
entryComponent?: boolean;
type?: string;
standalone?: boolean;
changeDetection?: 'Default' | 'OnPush';
}
9 changes: 8 additions & 1 deletion packages/schematics/component/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
"format": "html-selector",
"description": "The selector to use for the page"
},
"createModule": {
"createModule": {
"type": "boolean",
"description": "Allows creating an NgModule for the component",
"default": false
Expand Down Expand Up @@ -90,6 +90,13 @@
"type": "boolean",
"description": "Specifies if the component should be standalone",
"default": false
},
"changeDetection": {
"type": "string",
"description": "Specifies the change detection strategy used by the component",
"enum": ["Default", "OnPush"],
"default": "Default",
"alias": "c"
}
},
"required": []
Expand Down