JSFiddle - React, Tailwind, and code Playground
by Adam Doherty
HTML
<div ng-app="myApp">
<ul ng-controller="TestCtrl">
<li ng-repeat="item in data.webapps_1.items | selectedTags:tags">{{ item.name }}</li>
</ul>
</div>
JavaScript
angular.module('myApp', [])
.filter('selectedTags', function () {
return function (items, tags) {
var filtered = [];
angular.forEach(items, function (item) {
angular.forEach(tags, function (tag) {
if (item.itemid == tag) {
filtered.push(item);
}
});
});
return filtered;
};
})
.controller('TestCtrl', function ($scope) {
//this is my array
$scope.tags = ['1195986', '1195987', '1195988'];
//this is my json
$scope.data = {
"moduleName": null,
"contentholder_0": {
"moduleName": "contentholder",
"id": "-1",
"name": "",
"content": ""
},
"webapps_1": {
"moduleName": "webapps",
"items": [{
"itemid": "1195986",
"name": "abc"
}, {
"itemid": "1195987",
"name": "def"
}, {
"itemid": "1195988",
"name": "ghi"
}]
}
};
});