【发布时间】:2019-05-09 21:07:55
【问题描述】:
我想构建一个基于角材料库的自定义库,因此我将角材料添加到我的角项目中,并在我的组件中测试了材料组件,它运行良好。但是在我尝试在创建 VIA ng 生成库的库中使用角度材料之后,我被错误淹没了。
错误:
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>
【问题讨论】:
-
组件运行良好。但不能在自定义库中工作。谢谢
标签: angular angular-material angular-cli