如今有兩個數組,數組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"}]
世界只因有你2017-05-15 16:53:48
html
<p ng-repeat="td in test1"> <p id="{{td.id}}"> <p>该id对应的数值是:{{test2[0].idnum[td.id]}}<p> </p> </p>
不知是否是要這樣?