I'm trying to use Angular Material in an Ionic 4 Project. I have already installed all the dependencies needed through NPM. In order to get a more clean and maintainable code, I've created a separate ngModule
which imports all the components that I need in my application,following the Angular Material Docs(the Getting Start part).
Then, I've imported it in the page module where I want to use it.
However, when I want to start the material component, It looks like the import is not being used, so I can't use the component.
I've tried to import the material components module directly in the app.module.ts file, with the same results.I could just import each component that I want to use directly,instead of the module with all of them, but I really want to know why this approach is not working, and if is there anything I'm not doing correctly.
So this is how my custom module looks:
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import {BrowserAnimationsModule} from '@angular/platform-browser/animations';
import {MatButtonModule} from '@angular/material';
import {MatDialogModule} from '@angular/material/dialog';
@NgModule({
declarations: [],
imports: [
CommonModule,
BrowserAnimationsModule,
MatButtonModule,
MatDialogModule
],
exports: [
MatDialogModule,
MatButtonModule
]
})
export class AppMaterialModule { }
And this how I'm trying to import it where I want to use it:
import { AppMaterialModule} from '../../app-material.module';
@NgModule({
declarations: [],
imports: [
AppMaterialModule,
....
]
...
I expect to be able to use all the material components imported in AppMaterialModule
just including this module where I'm using then, but somehow this approach is not working.
Thanks for your help.