ngfor angular2得到迭代的vlaue
问题描述:
我环路上的对象ngfor angular2得到迭代的vlaue
这里的数组服务器基础contnet是循环
<div class="col-lg-3 col-md-5 col-sm-10 col-xs-10 box" *ngFor="let partner of foundPartners" >
<div class="alert">go to webservice for each item in the loop and write alerts here base on the id</div>
</div>
的HTML现在在每次循环,我需要获得该项目的ID然后转到webservice api并获取该项目的一些数据库并在厄运内打印它。
我曾经与asp.net转发器一起工作,在那里你有ItemDataBound事件,可以获取该项目,然后对它的厄运基地进行一些更改。
在angular2中有类似的东西吗?我怎么能从循环中的项目的API基础拉数据,并写入厄运?
答
你可以为它创建自己管:
<div class="col-lg-3 col-md-5 col-sm-10 col-xs-10 box" *ngFor="let partner of foundPartners" >
<div class="alert"><div *ngFor="let partnerData of (partner?.id | fetch) ">
{{partnerData}}
</div></div>
</div>
https://angular.io/docs/ts/latest/guide/pipes.html#!#an-impure-caching-pipe
答
我觉得你可以循环数组和一些API在组件每个项目获得的数据。在这种情况下,您可以创建包含所有必要信息的数组,并将其显示在模板中