My question is: How can I import Angular material modules into a proper module, and then import that module into app.module.ts?
This is my personal module:
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatMenuModule } from '@angular/material/menu';
import { MatButtonModule } from '@angular/material/button';
@NgModule({
imports: [
BrowserAnimationsModule,
MatMenuModule,
MatButtonModule
],
declarations: [
]
})
export class MaterialModule { }
with which what I do is the following in app.module.ts:
import {MaterialModule} from './material.module';
import array:
imports: [
BrowserModule,
AppRoutingModule,
HttpClientModule,
FormsModule,
MaterialModule
],
The thing is that I get errors, but if I do it directly everything in app.module.ts works for me. I don't want to have everything imported in the same module, so as not to make it difficult when reviewing or correcting code. Thanks in advance, regards.
You must export the modules as well so that they can be used in different modules, you just have to add an array with the exports property to your NgModule