在 Angular 9 中的 *ngFor 中存在问题,当我尝试在锚标记中使用它时,它显示"No Directive is matched on attribute ngFor"


<a *ngFor="let recipe for recipes" href="#" class="list-group-item clearfix">
<div class="pull left">
<h4 class="list-group-item-heading">{{ recipe.name }}</h4>
<p class="list-group-item-text">{{ recipe.description }}</p>
<span class="pull-right">
<img src="" alt="{{recipe.name}}" class="img-responsive" style="max-height: 50px"/>
</span>
</div>
</a>

由于此消息,我无法在此处使用ngFor指令

打字错误:

与其使用let recipe for recipes,不如使用类似的:

<a *ngFor="let recipe of recipes" href="#" class="list-group-item clearfix">

最新更新