angular.js - angularjs如何将两个数组的数据进行匹配?
阿神
阿神 2017-05-15 16:51:48
0
2
509

如今有两个数组,数组test1里id的值和test2里的值是对应的,那么现在想要实现,如果test1 id值=test2.idnum里的id值的话,就把test2.idnum里的id值对应的数字输出到p标签里。请问这个要怎么做匹配并且把值写到p标签内?用filter可以做到吗?

html:

<p ng-repeat="td in test1">
<p id="{{td.id}}">
<p>该id对应的数值是:{{...}}<p>
</p>
</p>

第一个数组

$scopt.test1=[{
"id": "x01",
"imgurl": "images/banner_01.jpg",
"status": "0"
},
{
"id": "x02",
"imgurl": "images/banner_01.jpg",
"status": "0"
},
{
"id": "x03",
"imgurl": "images/banner_01.jpg",
"status": "0"
}]

第二数组

$scopt.test2=[{"dco":"xsadsq112341",
"reqs":"yes",
"idnum":{"x01":"1","x02":"3","x03":"0"}]
阿神
阿神

闭关修行中......

reply all(2)
世界只因有你
html<p ng-repeat="td in test1">
<p id="{{td.id}}">
<p>该id对应的数值是:{{test2[0].idnum[td.id]}}<p>
</p>
</p>

I wonder if this is the case?

滿天的星座

Filter can
ng-if can also be used

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template