angular.js - How to match the data of two arrays in angularjs?
阿神
阿神 2017-05-15 16:51:48
0
2
524

Now there are two arrays. The id value in array test1 corresponds to the value in test2. So now we want to implement, if the test1 id value = the id value in test2.idnum, put the id value in test2.idnum The number corresponding to the id value is output to the p tag. How do I do this matching and write the value into the p tag? Can this be done using filter?

html:

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

First array

$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"
}]

Second array

$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