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 bcfd2fa5547e..21c884bd80e8 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,10 +1,9 @@ -import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core';<% if(standalone) {%> -import { CommonModule } from '@angular/common';<% } %> +import { <% if(changeDetection !== 'Default') { %>ChangeDetectionStrategy, <% }%>Component<% if(!!viewEncapsulation) { %>, ViewEncapsulation<% }%> } from '@angular/core'; @Component({<% if(!skipSelector) {%> selector: '<%= selector %>',<%}%><% if(standalone) {%> standalone: true, - imports: [CommonModule],<%}%><% if(inlineTemplate) { %> + imports: [],<%}%><% if(inlineTemplate) { %> template: `

<%= dasherize(name) %> works! diff --git a/packages/schematics/angular/component/index_spec.ts b/packages/schematics/angular/component/index_spec.ts index 776a75b1df5c..8a068c02590a 100644 --- a/packages/schematics/angular/component/index_spec.ts +++ b/packages/schematics/angular/component/index_spec.ts @@ -340,11 +340,9 @@ describe('Component Schematic', () => { const tree = await schematicRunner.runSchematic('component', options, appTree); const moduleContent = tree.readContent('/projects/bar/src/app/app.module.ts'); const componentContent = tree.readContent('/projects/bar/src/app/foo/foo.component.ts'); - expect(componentContent).toContain('@angular/common'); expect(componentContent).toContain('class FooComponent'); expect(moduleContent).not.toContain('FooComponent'); expect(componentContent).toContain('standalone: true'); - expect(componentContent).toContain('imports: [CommonModule]'); }); it('should declare standalone components in the `imports` of a test', async () => {