美文网首页Angular
No directive is matched on attri

No directive is matched on attri

作者: survivorsfyh | 来源:发表于2020-11-25 15:47 被阅读0次

在 html 模块调用 *ngFor 的时候抛出了如下异常信息:

No directive is matched on attribute ngFor 

原因是在 module 中未引入 CommonModule 模块;

解决办法

在对应组件的 module 中引入 CommonModule 模块即可;

import {CommonModule} from '@angular/common';

@NgModule({
  imports: [
    CommonModule,
  ]
})

注:*ngIf 和 *ngFor 同理


以上便是此次分享的全部内容,希望能对大家有所帮助!

相关文章

网友评论

    本文标题:No directive is matched on attri

    本文链接:https://www.haomeiwen.com/subject/vqeniktx.html