Я создал angular модуль материала (как основной модуль).
import { NgModule} from '@angular
import {MatCheckboxModule} from '@angular/material/checkbox';
@NgModule({
imports: [
MatCheckboxModule
],
exports: [
MatCheckboxModule
],
})
export class MaterialModule { }
И я хочу добавить этот модуль в другой модуль:
import { NgModule} from '@angular/core';
import { TestModuleRoutingModule } from './test-module-routing.module';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { BrowserModule } from '@angular/platform-browser';
import { MaterialModule } from '../material/';
import { ModuleIntTestComponent } from './module-int-test/module-int-test.component';
@NgModule({
imports: [
BrowserModule,
TestModuleRoutingModule,
BrowserAnimationsModule,
MaterialModule
],
exports: [
MaterialModule
],
declarations: [ModuleIntTestComponent],
})
export class TestModuleModule { }
Затем внутри ModuleIntTestComponent я хочу использовать флажок angular материала.
<p>module-int-test works!</p>
<mat-checkbox class="example-margin">Checked</mat-checkbox>
но я получаю следующую ошибку:
***ERROR in src/app/test-module/module-int-test/module-int-test.component.html:3:1 - error NG8001: 'mat-checkbox' is not a known element:
1. If 'mat-checkbox' is an Angular component, then verify that it is part of this module.
2. If 'mat-checkbox' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3 <mat-checkbox class="example-margin">Checked</mat-checkbox>
src/app/test-module/module-int-test/module-int-test.component.ts:6:16
6 templateUrl: './module-int-test.component.html',
Error occurs in the template of component ModuleIntTestComponent.***
Что отсутствует или что не так?
Я не могу понять.
Примечание. Если я добавлю свой MaterialModule в AppModule, я могу без проблем использовать флажок Material в любом компоненте AppModule.