diff --git a/packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template b/packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template index c033cca53af0..826be9629e26 100644 --- a/packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template +++ b/packages/schematics/angular/component/files/__name@dasherize@if-flat__/__name@dasherize__.__type@dasherize__.ts.template @@ -1,4 +1,4 @@ -import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component, OnInit<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core';<% if(standalone) {%> +import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core';<% if(standalone) {%> import { CommonModule } from '@angular/common';<% } %> @Component({<% if(!skipSelector) {%> @@ -22,11 +22,6 @@ import { CommonModule } from '@angular/common';<% } %> encapsulation: ViewEncapsulation.<%= viewEncapsulation %><% } if (changeDetection !== 'Default') { %>, changeDetection: ChangeDetectionStrategy.<%= changeDetection %><% } %> }) -export class <%= classify(name) %><%= classify(type) %> implements OnInit { - - constructor() { } - - ngOnInit(): void { - } +export class <%= classify(name) %><%= classify(type) %> { } diff --git a/packages/schematics/angular/component/index_spec.ts b/packages/schematics/angular/component/index_spec.ts index d887a524b0d7..ef8ab68f3ddf 100644 --- a/packages/schematics/angular/component/index_spec.ts +++ b/packages/schematics/angular/component/index_spec.ts @@ -297,7 +297,7 @@ describe('Component Schematic', () => { const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise(); const content = tree.readContent('/projects/bar/src/app/foo/foo.route.ts'); const testContent = tree.readContent('/projects/bar/src/app/foo/foo.route.spec.ts'); - expect(content).toContain('export class FooRoute implements OnInit'); + expect(content).toContain('export class FooRoute'); expect(testContent).toContain("describe('FooRoute'"); expect(tree.files).toContain('/projects/bar/src/app/foo/foo.route.css'); expect(tree.files).toContain('/projects/bar/src/app/foo/foo.route.html'); @@ -308,7 +308,7 @@ describe('Component Schematic', () => { const tree = await schematicRunner.runSchematicAsync('component', options, appTree).toPromise(); const content = tree.readContent('/projects/bar/src/app/foo/foo.ts'); const testContent = tree.readContent('/projects/bar/src/app/foo/foo.spec.ts'); - expect(content).toContain('export class Foo implements OnInit'); + expect(content).toContain('export class Foo'); expect(testContent).toContain("describe('Foo'"); expect(tree.files).toContain('/projects/bar/src/app/foo/foo.css'); expect(tree.files).toContain('/projects/bar/src/app/foo/foo.html');