Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular filter on child property

Tags:

angularjs

Hi I need to filter an angular list based on a child property.

I have this model:

  $scope.data = [{name:"John",type:{talent:"genius"}},
                 {name:"Paul",type:{talent:"genius"}},
                 {name:"Ringo",type:{talent:"lucky"}}];

I need to display a list of name of only talented people. So I was trying something like this:

item in data|myFilter:item.type

http://jsbin.com/ObIqUyix/1/edit

like image 236
Tropicalista Avatar asked Dec 14 '13 02:12

Tropicalista


1 Answers

This is better because it'll let you have other properties in the type object as well and you can still filter using different properties:

item in data | filter: {type:{talent:'genius'}}:true
like image 106
AD.Net Avatar answered Oct 24 '22 21:10

AD.Net