代码之家  ›  专栏  ›  技术社区  ›  AngularM

角材料芯片不适用于角版本7

  •  0
  • AngularM  · 技术社区  · 6 年前

    角材料芯片不适用于角版本7

    :Angular版本7,Angular cli,Angular材质。

    我想要的结果:

    我做过的事情:

    • 我已安装“@angular/material”:“^7.3.3”和“@angular/animations”:“^7.2.6”,

    • 我的应用程序模块中的我的导入:

      从“@angular/material/chips”导入{MatChipsModule}; 从“@angular/material”导入{MatCommonModule,MatInputModule};

    这是我的组成部分:

              <mat-form-field>
                <mat-chip-list #chipList>
                  <mat-chip>Chip 1</mat-chip>
                  <mat-chip>Chip 2</mat-chip>
                </mat-chip-list>
                <input [matChipInputFor]="chipList">
              </mat-form-field>
    

    我得到的错误:

    “mat chip list”不是已知元素

    enter image description here

    0 回复  |  直到 6 年前
        1
  •  2
  •   Igor    6 年前

    import { NgModule } from '@angular/core';
    import { BrowserModule } from '@angular/platform-browser';
    import { FormsModule } from '@angular/forms';
    import { NoopAnimationsModule, BrowserAnimationsModule } from '@angular/platform-browser/animations';
    import {MatChipsModule} from '@angular/material/chips';
    import {MatCommonModule, MatInputModule} from '@angular/material';
    
    
    import { AppComponent } from './app.component';
    
    @NgModule({
      imports:      [ BrowserModule, FormsModule, NoopAnimationsModule, MatChipsModule, BrowserAnimationsModule,MatInputModule,MatCommonModule ],
      declarations: [ AppComponent ],
      bootstrap:    [ AppComponent ]
    })
    export class AppModule { }
    

    这是一个 stackblitz of your code

        2
  •  0
  •   Rahul    5 年前

    import {MatCommonModule, MatInputModule, MatChipsModule} from '@angular/material';
    
    @NgModule({
     imports: [
       ...
     ],
     exports: [
       ...,
       MatChipsModule
     ]
    })
    
    推荐文章