I've simplified this as much as possible. I'm using angularjs, I have a controller with an array of json objects like this:
controller('simpleC', function ($scope) {
$scope.myArrayOfValues = [
{
"name" : "name1",
"extra": "data"
},
{
"name" : "name2",
"extra": "data"
},
{
"name" : "name3",
"extra": "data"
}
];
});
In my html view I want to quickly find a specific json object from that array based on the value of name. Obviously what I have written below is wrong but the result of it is what I want.
<div ng-show="myArrayOfValues['name2']"></div>
Is there an angular feature I can use to go about this that will avoid me having to create a for loop or hash map?
{{ (myArrayOfValues | filter : {name: 'name2' })[0].extra }}