Material 官網:https://material.angular.iocss
step 1: npm install --save @angular/material @angular/cdk step 2: npm install --save @angular/animations step 3: angular.cli "../node_modules/@angular/material/prebuilt-themes/indigo-pink.css" or style.css @import "~@angular/material/prebuilt-themes/indigo-pink.css"; step 4: index.html <link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> step 5: app.module.ts import {MatInputModule, MatCardModule, MatButtonModule} from "@angular/material"; import {BrowserAnimationsModule} from '@angular/platform-browser/animations'; imports:[ BrowserAnimationsModule, MatInputModule, MatCardModule, MatButtonModule, ]
這幾天看到 angular已經更新到了6,本着好奇的心態去看了下,發現 angular 6上面添加 material 變的簡單多了。只須要一行命令就能夠搞定。html
進入到工程目錄下node
ng add @angular/material
圖示:
npm
Ag-grid 官網:https://www.ag-grid.com/json
step 1: npm install --save ag-grid-angular ag-grid step 2: angular.cli "../node_modules/ag-grid/dist/styles/ag-grid.css", "../node_modules/ag-grid/dist/styles/ag-theme-fresh.css" step 3: app.module.ts imports:[ AgGridModule.withComponents([]) ], exports:[ AgGridModule ]
NG-ZORRO 官網:https://ng.ant.design/version...bootstrap
step 1: npm install ng-zorro-antd --save step 2: 直接用下面的代碼替換 /src/app/app.module.ts 的內容
注意:在根 module 中須要使用 NgZorroAntdModule.forRoot(),在子 module 須要使用 NgZorroAntdModule
import { BrowserModule } from '@angular/platform-browser'; import { BrowserAnimationsModule } from '@angular/platform-browser/animations'; import { NgModule } from '@angular/core'; import { FormsModule } from '@angular/forms'; import { HttpClientModule } from '@angular/common/http'; import { NgZorroAntdModule } from 'ng-zorro-antd'; import { AppComponent } from './app.component'; @NgModule({ declarations: [ AppComponent ], imports: [ BrowserModule, FormsModule, HttpClientModule, BrowserAnimationsModule, NgZorroAntdModule.forRoot() ], bootstrap: [AppComponent] }) export class AppModule { }
step 3: 修改 .angular-cli.json 文件的 styles 列表 "styles": [ "../node_modules/ng-zorro-antd/src/ng-zorro-antd.less" ]