I want to switch from SCAM to angular standalone component design. I started by creating a new component but I keep getting the the error:
class ExpansionTableComponent Appears in the NgModule.imports of SMVHistoryComponentModule, but could not be resolved to an NgModule class.
Is it missing an @NgModule annotation?(-996002)
I'm using following packages:
Angular CLI: 14.2.10
Node: 14.20.0
Package Manager: npm 6.14.17
OS: linux x64
@angular-devkit/architect 0.1402.10
@angular-devkit/build-angular 14.2.10
@angular-devkit/core 14.2.10
@angular-devkit/schematics 14.2.10
@angular/cdk 14.2.7
@angular/cli 14.2.10
@angular/google-maps 14.2.7
@angular/material 14.2.7
@angular/material-moment-adapter 14.2.7
@schematics/angular 14.2.10
rxjs 6.6.3
typescript 4.6.4
This is my component setup:
ExpansionTableComponent:
@Component({
selector: 'app-expansion-table',
templateUrl: './expansion-table.component.html',
styleUrls: ['./expansion-table.component.scss'],
standalone: true,
imports: [CommonModule, MatExpansionModule, MatTableModule]
})
export class ExpansionTableComponent implements OnChanges {
@Input() tableData: ExpansionTableData[];
ngOnChanges(changes: SimpleChanges): void {
console.log(this.tableData);
}
}
And imported it as suggested by the angular guide ([https://angular.io/guide/standalone-components](Angular Standalone Component Guide)) in a SCAM component:
@Component({
selector: 'app-smv-history',
templateUrl: './smv-history.component.html',
styleUrls: ['./smv-history.component.scss'],
providers: [SMVHistoryService]
})
export class SMVHistoryComponent {}
@NgModule({
declarations: [SMVHistoryComponent],
exports: [SMVHistoryComponent],
imports: [
CommonModule,
MatCardModule,
MatTableModule,
MatIconModule,
MatButtonModule,
MomentModule,
MatFormFieldModule,
MatInputModule,
FormsModule,
ReactiveFormsModule,
MatDatepickerModule,
MatPaginatorModule,
MatDialogModule,
ProcessResultDialogComponentModule,
TranslateModule.forChild(),
ExpansionTableComponent
]
})
export class SMVHistoryComponentModule {}
This builds and the application is working as expected. However I get the following Error in VSCode: VSCode Error
I can't get rid of this error, has anyone an idea on how to fix this?