I've integrated the Angular Material module into my project by updating the material.module.ts file with the following imports:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { MatToolbarModule } from '@angular/material/toolbar';
import { MatIconModule } from '@angular/material/icon';
import { MatButtonModule } from '@angular/material/button';
import { MatDialogModule } from '@angular/material/dialog';
import { MatFormFieldModule } from '@angular/material/form-field';
import { MatSelectModule } from '@angular/material/select';
import { MatInputModule } from '@angular/material/input';
import { MatDatepickerModule } from '@angular/material/datepicker';
@NgModule({
declarations: [],
imports: [
CommonModule,
MatToolbarModule,
MatIconModule,
MatButtonModule,
MatDialogModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule,
MatDatepickerModule,
],
exports: [
MatToolbarModule,
MatIconModule,
MatButtonModule,
MatDialogModule,
MatFormFieldModule,
MatSelectModule,
MatInputModule,
MatDatepickerModule,
],
})
export class MaterialModule {}
In my code, I repeated the same modules in both the imports and exports sections. To avoid this duplication, is there a way to condense the code like this:
importsAM = [
MatFormFieldModule,
MatSelectModule,
MatInputModule,
MatDatepickerModule,
]
@NgModule({
declarations: [],
imports: [
CommonModule,
importsAM
],
exports: [
importsAM
],
})
Is it possible to achieve a more concise syntax or reduce the repetitive code?