How To Filter Objects Based On Value Of Key Given Inside Same Object
I have list of objects where I have to filter the objects based on value of a key present inside same object and create
tag with content. List of objects: { 'status
Solution 1:
You can use filters by Angular in a shorter way. e.g. You can filter in the ng-repeat.
So, your ng-repeat will be something like this:
<ling-repeat="wd in elements | filter:search"><ang-click=" viewProject(wd) "href=" "><h4>{{wd.name}}</h4
</a><p>Status: {{wd.status}}</p></li>
Where the search is a new element where you set the fiters elements. In my case I use:
<spanclass="btn btn-default"ng-click="search.status=''">No Filters</span><spanclass="btn btn-primary"ng-click="search.status='OPEN'">Show Open</span><spanclass="btn btn-success"ng-click="search.status='IN PROGRESS'">Show In Progress</span>
You can check how it works, in the Plunkr: https://plnkr.co/edit/5V3Rg0lggjnPVFu3srsG?p=preview
Solution 2:
You can use filter method to filter out the required data
var _getResult = myArray[0].result;
var filterArray = _getResult.filter(function(item){
return item.status ==="OPEN" || item.status === "IN PROGRESS"
})
console.log(filterArray)
See this jsfiddle
Solution 3:
You can use ng-if to filter the items.codepen url for reference http://codepen.io/nagasai/pen/MeaawO
<ling-repeat="wd in currentPageWorkOrders.result"ng-if="wd.status == 'OPEN'"><ang-click="viewProject(wd)"href=""><h4 >{{wd}}</h4></a></li>
Hope this is helpful for you
Post a Comment for "How To Filter Objects Based On Value Of Key Given Inside Same Object"