Angular material Can';t向角度模块添加材质

Angular material Can';t向角度模块添加材质,angular-material,angular9,Angular Material,Angular9,我试图找到如何添加角材质,以处理划分为模块的角材质。它只能在根目录下工作,但不能在模块中工作 ng add @angular/material package.json "dependencies": { "@angular/animations": "^9.1.0-rc.2", "@angular/cdk": "^9.1.3", "@angular/common": "~9.1.0-rc.1", "@angular/compiler": "~9.1.0-rc.

我试图找到如何添加角材质,以处理划分为模块的角材质。它只能在根目录下工作,但不能在模块中工作

ng add @angular/material
package.json

"dependencies": {
    "@angular/animations": "^9.1.0-rc.2",
    "@angular/cdk": "^9.1.3",
    "@angular/common": "~9.1.0-rc.1",
    "@angular/compiler": "~9.1.0-rc.1",
    "@angular/core": "~9.1.0-rc.1",
    "@angular/forms": "~9.1.0-rc.1",
    "@angular/material": "^9.1.3",
    "@angular/platform-browser": "~9.1.0-rc.1",
    "@angular/platform-browser-dynamic": "~9.1.0-rc.1",
    "@angular/router": "~9.1.0-rc.1",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.901.0-rc.0",
    "@angular/cli": "~9.1.0-rc.0",
    "@angular/compiler-cli": "~9.1.0-rc.1",
    "@angular/language-service": "~9.1.0-rc.1",
    "@types/node": "^12.11.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  }
home.module.ts

import { CommonModule } from '@angular/common';
import { NgModule } from '@angular/core';
import { BrowserAnimationsModule } from '../../../node_modules/@angular/platform-browser/animations';
import { HomeRoutingModule } from './home-routing.module';
import { HomeComponent } from './home/home.component';
import { MatCardModule } from '@angular/material/card';
@NgModule({
  declarations: [HomeComponent],
  imports: [
    CommonModule,
    HomeRoutingModule,
    MatCardModule,
    BrowserAnimationsModule,
  ],
})
export class HomeModule { }
还有my home.component.html

<p>home works!</p>
<mat-card>Simple card</mat-card>
以抑制此消息

我尝试将物料卡模块导入app.module.ts。但它只能在根组件中工作,而不能在模块中工作

ERROR in src/app/home/home/home.component.html:2:1 - error NG8001: 'mat-card' is not a known element:
1. If 'mat-card' is an Angular component, then verify that it is part of this module.
2. If 'mat-card' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component