Integrating third-party UI frameworks and components for Angular study notes

Install Material UI method:

Material official website: https://material.angular.io

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,
    ]

How to install Ag-grid

Ag-grid official website: https://www.ag-grid.com/

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
]

How to install NG-ZORRO

NG-ZORRO official website: https://ng.ant.design/version/0.7.x/docs/introduce/zh

step 1:
npm install ng-zorro-antd --save

step 2:
直接用下面的代码替换 /src/app/app.module.ts 的内容

Note: NgZorroAntdModule.forRoot() needs to be used in the root module, and NgZorroAntdModule needs to be used in the child module

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"
]

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325684472&siteId=291194637