angular.js - Is there any way in angularjs to match array data based on an id value?
黄舟
黄舟 2017-05-15 16:51:29
0
1
534

My idea is this, when clicking the a tag of the html, pass the id of p through the url to be received by another js page, and then use this id to match in the array (TU), if id== tuid outputs the data of the group where the tuid is located one by one to the corresponding location of an html page.

Now I have received the value, but I don’t know how to match the data in the data and then output the required data. Please give me some advice, seniors.

Received id:

 var productNo=common.getQueryString("productNo");

The array structure is as follows:

var TU = [{
    "tuid":"xy0001",
    "imgurl":"img/178.jpg",
    "title":"安全椅",
    "cost":"86"
},
    {
    "tuid":"xy0002",
    "imgurl":"img/178.jpg",
    "title":"时尚包",
    "cost":"96"
},
{
    "tuid":"xy0003",
    "imgurl":"img/178.jpg",
    "title":"娃娃",
    "cost":"89"
}
]

html page:

<p class=“xsy”> 
<img src="{{imgurl}}"> 
<h1>{{title}}</h1> 
<p>{{cost}}</p></p>
黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

reply all(1)
曾经蜡笔没有小新

Initialize a variable, which is empty by default.

$scope.query = '';

Assign the passed value to this variable,
Loop through

ng-repeat="v in TU | filter:{'tuid':query}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template