I created a project using the Angular-Cli tool and I installed it together
npm install --save @ angular / material @ angular / cdk
npm install --save @ angular / animations
And as the documentation itself explains, I imported the modules of the angular material into a separate file: (angular-material-module.ts):
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { BrowserAnimationsModule } from '@angular/platform-
browser/animations';
import { FlexLayoutModule } from '@angular/flex-layout';
import { MatCardModule, MatIconModule, MatToolbarModule, MatButtonModule,
MatFormFieldModule, MatInputModule } from '@angular/material';
@NgModule({
imports: [
CommonModule,
BrowserAnimationsModule,
FlexLayoutModule,
MatCardModule,
MatIconModule,
MatToolbarModule,
MatButtonModule,
MatFormFieldModule,
MatInputModule
],
exports: [
BrowserAnimationsModule,
FlexLayoutModule,
MatCardModule,
MatIconModule,
MatToolbarModule,
MatButtonModule,
MatFormFieldModule,
MatInputModule
]
})
export class AngularMaterialModule { }
Then I imported the module into my main module (app.module.ts):
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AngularMaterialModule } from './compartilhado/angular-
material/angular-material.module';
import { AppComponent } from './app.component';
import { AppRoutingModule } from './app.routing';
import { MainModule } from './main/main.module';
@NgModule({
declarations: [AppComponent],
imports: [
BrowserModule,
AppRoutingModule,
AngularMaterialModule,
MainModule
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
To test if everything was working correctly, I inserted some components on the initial screen app.component.html, so it worked correctly.
But I created some sub modules of the main module, as exemplified in the image below:
Beingthuswithinthecomponent-curriculo.component.htmlcomponent,Iwenttousethecomponentsoftheangular-material,howeverpresentedanerror,statingthattheangular-materialelementswerenotfound:
For test purposes, I imported the module I had created with the angular-material components (AngularMaterialModule) directly into the component module (CadastroCurriculoModule), it worked there ...
I would like to know if it is possible for me to import the module (AngularMaterialModule) that I created with the angular-material components, in a global way, and become available for all modules and components of the project.