我想基于角度材料库构建一个自定义库,因此我将角度材料添加到我的角度项目中,并在其组件中测试了材料组件,使其工作良好。但是,当我尝试通过VIA ng generate库在创建的库中使用角形材料时,我就充满了错误。
错误:
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>
")
我试图在导入和导出库中添加物料模块,但没有任何效果
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
<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>
答案 0 :(得分:0)
尝试将CommonModule添加到tabs.module.ts的导入中