简体   繁体   English

无法将角度材质添加到角度自定义库

[英]Unable To Add Angular Material To Angular Custom Library

I want to build a custom library based on angular material library so i added angular material to my angular project and tested material components in my components it worked well. 我想基于角度材料库构建一个自定义库,所以我将角度材料添加到我的角度项目中,并在我的组件中测试了材料组件,它运行良好。 But after i tried to use angular material in library created VIA ng generate library then i was flooded with errors. 但是在我试图在库中使用角度材料创建了VIA ng生成库之后,我就被充斥着错误。

Errors: 错误:

BUILD ERROR
: Can't bind to 'ngForOf' since it isn't a known property of 'mat-tab'.
1. If 'mat-tab' is an Angular component and it has 'ngForOf' input, then verify that it is part of this module.
2. If 'mat-tab' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '@NgModule.schemas' of this component to suppress this message.
3. To allow any property add 'NO_ERRORS_SCHEMA' to the '@NgModule.schemas' of this component. ("<div class="pwc-tabs">
  <mat-tab-group disableRipple>
    <mat-tab  [ERROR ->]*ngFor="let tab of tabContent" label="{{tab.title}}"> {{tab.content}} </mat-tab>
  </mat-tab-group>

")

i tried to add material modules in library imports and exports nothing worked 我试图在库导入和导出中添加材料模块没有任何工作

tabs.module.ts tabs.module.ts

import { NgModule } from '@angular/core';
import { TabsComponent } from './tabs.component';
import { MatTabsModule } from '@angular/material/tabs';
import { MatExpansionModule } from '@angular/material/expansion';

@NgModule({
  declarations: [TabsComponent],
  imports: [
    MatTabsModule,
    MatExpansionModule
  ],
  exports: [
    MatTabsModule,
    MatExpansionModule,
    TabsComponent
  ]
})
export class TabsModule { }

tabs.html tabs.html

<div class="tabs">
  <mat-tab-group disableRipple>
    <mat-tab  *ngFor="let tab of tabContent" label="{{tab.title}}"> {{tab.content}} </mat-tab>
  </mat-tab-group>

  <mat-expansion-panel #tabsExpansionPanel>
    <mat-expansion-panel-header>
      <mat-panel-description>
        <i *ngIf="!tabsExpansionPanel.expanded" class="material-icons expansion-panel-icons">
          keyboard_arrow_down
        </i>
        <i *ngIf="tabsExpansionPanel.expanded" class="material-icons expansion-panel-icons">
          keyboard_arrow_up
        </i>
      </mat-panel-description>
    </mat-expansion-panel-header> 
  </mat-expansion-panel>
</div>

尝试将CommonModule添加到tabs.module.ts的导入中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM