在 html 模块调用 *ngFor 的时候抛出了如下异常信息:
No directive is matched on attribute ngFor
原因是在 module 中未引入 CommonModule 模块;
解决办法
在对应组件的 module 中引入 CommonModule 模块即可;
import {CommonModule} from '@angular/common';
@NgModule({
imports: [
CommonModule,
]
})
注:*ngIf 和 *ngFor 同理
以上便是此次分享的全部内容,希望能对大家有所帮助!
网友评论