Angular 材质不适用于 Angular13

Asa*_*n A 5 angular-material angular

我在我的项目中安装了 Angular Material,但没有加载。

我尝试将样式表导入全局 Style.css

重新启动服务器

但角度材质并未更新。

我没有任何线索。

下面我也添加了我的 Package.Json 文件

我的 HTML 代码


<mat-form-field>
  <textarea MatInput rows="6" [(ngModel)]="valueEntered"></textarea>
</mat-form-field>

<hr />
<button (click)="onSave()">Save</button>
<p>{{ newPost }}</p>
Run Code Online (Sandbox Code Playgroud)

应用程序模块代码

import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

import { postCreateComponent } from './posts/post-create/post-create.component';

import { FormsModule } from '@angular/forms';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; 
import {MatInputModule} from '@angular/material/input';

@NgModule({
  declarations: [
    AppComponent,
    postCreateComponent
  ],
  imports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    BrowserAnimationsModule,
    MatInputModule
  ],
  exports: [
    BrowserModule,
    AppRoutingModule,
    FormsModule,
    BrowserAnimationsModule,
    MatInputModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

Run Code Online (Sandbox Code Playgroud)

打包 Json 文件

"dependencies": {
    "@angular/animations": "~13.2.0",
    "@angular/cdk": "^13.3.9",
    "@angular/common": "~13.2.0",
    "@angular/compiler": "~13.2.0",
    "@angular/core": "~13.2.0",
    "@angular/forms": "~13.2.0",
    "@angular/material": "^13.3.9",
    "@angular/platform-browser": "~13.2.0",
    "@angular/platform-browser-dynamic": "~13.2.0",
    "@angular/router": "~13.2.0",
    "rxjs": "~7.5.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.11.4"
  },
Run Code Online (Sandbox Code Playgroud)

Joo*_*rts 1

应该将ng add @angular/material和 添加到NgModule MatFormFieldModule和的导入和导出中BrowserAnimationsModule