Skip to content

Commit 3eab216

Browse files
committed
feat(@schematics/angular): remove ngOnInit from component template
This commit removes the `constructor` and `ngOnInit` as most of the users prefer to add this manually if needed. Closes #23678
1 parent fb5a66a commit 3eab216

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component, OnInit<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core';<% if(standalone) {%>
1+
import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core';<% if(standalone) {%>
22
import { CommonModule } from '@angular/common';<% } %>
33

44
@Component({<% if(!skipSelector) {%>
@@ -22,11 +22,6 @@ import { CommonModule } from '@angular/common';<% } %>
2222
encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>,
2323
changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %>
2424
})
25-
export class <%= classify(name) %><%= classify(type) %> implements OnInit {
26-
27-
constructor() { }
28-
29-
ngOnInit(): void {
30-
}
25+
export class <%= classify(name) %><%= classify(type) %> {
3126

3227
}

0 commit comments

Comments
 (0)