我安装了Angular Material Design.现在我尝试在app.module.ts文件中添加:
import { MaterialModule } from '@angular/material';
Run Code Online (Sandbox Code Playgroud)
我应该在一节中解释:imports: []?加载所有材料实体.
我试过了:imports: ['MaterialModule']但它已被弃用了
我是Angular / material2的新手,我不确定尝试遵循上的文档时会丢失什么sidenav。
在我的AppComponent中,我想显示一个sidenav,并实现如下:
app.component.tss
import {
NgModule,
Component
} from '@angular/core';
import {
MatSidenavModule,
MatSidenavContent,
MatSidenav
} from '@angular/material';
import {
BrowserAnimationsModule
} from '@angular/platform-browser/animations';
@NgModule({
imports: [
BrowserAnimationsModule,
MatSidenav
],
exports: [
BrowserAnimationsModule,
MatSidenav
]
})
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
title = 'app';
}
Run Code Online (Sandbox Code Playgroud)
app.component.html
<!--The content below is only a placeholder and can be replaced.-->
<mat-sidenav-container>
</mat-sidenav-container>
<div style="text-align:center">
<h1>
Welcome to {{ title }}!
</h1>
<nav> …Run Code Online (Sandbox Code Playgroud)