【发布时间】:2018-01-14 10:50:51
【问题描述】:
我正在使用 Angular 2 构建一个 Web 应用程序,并且想要循环使用列表项但在列表项之外的按钮,如何使用 *ngFor 获得功能>,请帮忙。
我的 HTML 代码:
<div class="col-xs-6">
<a class="list-group-item clearfix" style="background-color:rgb(3, 0, 48)" *ngFor="let buying of buy">
<div class="pull-left" style="max-width:350px">
<h5 style="color:white">{{buying.names}}</h5>
<p style="color:white">{{buying.desc}}</p>
</div>
<div>
<span class="pull-right" >
<img [src]="buying.getImg" alt="image not loaded" class="img-responsive" style="max-height:100px">
</span>
</div>
</a>
</div>
<div class="col-xs-6"> <-----I WANT TO LOOP THIS BUTTON
<button class="btn btn-primary ; pull-right">Add To Cart</button>
</div>
【问题讨论】:
-
您能否通过示例列表分享一些预期的输出
-
buy是对象还是数组,你能检查一下吗..? -
@chiragsorathiya 它是一个数组。
-
@RICKYKUMAR 我想做这样的(jqueryscript.net/images/…)
-
我认为提供的答案会对您有所帮助
标签: javascript html angular typescript ngfor