首页 > 解决方案 > *ngFor 在我添加引导程序之前工作,现在一切都坏了

问题描述

ngForOf嵌入式模板上的任何指令均未使用属性绑定。确保属性名称拼写正确并且所有指令都列在"@NgModule.declarations"

<div *ngFor="let post of posts" class="post-preview">
<h1 (click)="goToPost(post)" class="post-title">{{post.title}}</h1>
<p class="post-description">{{post.description}}</p>  </div>

在我使用引导程序添加样式之前一切正常

npm i -s bootstrap

标签: angularangular2-templateangular2-directives

解决方案


添加引导程序后;我添加imports: [CommonModule, ...],到我的家庭模块和工作再次。在添加引导程序之前,我刚刚CommonModule导入app.module.ts


推荐阅读