javascript - AngularJS filter with nested objects -
here i'm trying create list menu items food court. want filter out list based on search input box. angularjs default filter not applying filter on each of value present in list. example results populated i'm able filter out based on item name(like keywords idly, dosa) , price, not foodcourt name, vendor name(i.e kamath) , foodtype (i.e breakfast,lunch,dinner).
html:
<div ng-app="fcapp" ng-controller="fccontroller"> <div class="control"> <input type="search" ng-model="txtsearch" placeholder="search here"/> </div> <div id="menu"> <div ng-repeat="foodcourt in fcmenu" > <div ng-repeat="vendor in foodcourt.foodcourtdetails"> <div ng-repeat="foodtype in vendor.vendordetails"> <div class="fooditem" ng-repeat="fooddetails in foodtype.fooditemdetails | filter:txtsearch"> <div>{{fooddetails.itemname}} - {{foodtype.foodtypename}}</div> <div>{{vendor.vendorname}} - {{foodcourt.foodcourtname}}</div> <div>{{fooddetails.itemprice}}</div> </div> </div> </div> </div> </div> </div>
css:
*{margin:0;padding:0;}body{background:#000;color:#fff;} .control{display:block;margin:10px 0;} .control input{width:100% !important;box-sizing:border-box;} input[type="search"]{width:inherit;padding:0.7em 0.5em;} .fooditem{border:2px solid #ccc;border-radius:6px;margin:5px 0;}
javascript:
var fcjson = '[{"foodcourtname":"foodcourt1","foodcourtdetails":[{"vendorname":"adigas","vendordetails":[{"foodtypename":"breakfast","fooditemdetails":[{"itemname":"idly - 2 nos","itemdesc":"idly - 2 nos","itemprice":" rs. 20.00 ","itemcomposition":"60gms each + 80 ml chutney & 100 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"idly - vada ( 1 idly + vada )","itemdesc":"( 1 idly + vada )","itemprice":" rs. 25.00 ","itemcomposition":"60 gms each piece+ 80 ml chutney & 100 ml sambar","isvegetarian":"true","isspecial":"true"},{"itemname":"idly - vada ( 2 idly + vada )","itemdesc":"( 2 idly + vada )","itemprice":" rs. 35.00 ","itemcomposition":"60 gms each piece+ 80 ml chutney & 100 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"dosa - plain","itemdesc":"dosa - plain","itemprice":" rs. 25.00 ","itemcomposition":"80 gms + 60 ml chutney & 80 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"dosa","itemdesc":"masala/onion / rawa / ragi / vegetable / wheat /neer /ghee rost","itemprice":" rs. 32.00 ","itemcomposition":"150 gms + 80 ml chutney & 80 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"spl dosa","itemdesc":"ghee masala/rava masala","itemprice":" rs. 37.00 ","itemcomposition":"150 gm + 80 ml chutney & 80 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"sweet -","itemdesc":"sweet - payasam / jalebi / ladoo / gulab jamun / mysore pak / burfi / etc","itemprice":" rs. 10.00 ","itemcomposition":"80 ml / 35 gms","isvegetarian":"true","isspecial":"false"},{"itemname":"veg pulao","itemdesc":"veg pulao","itemprice":" rs. 34.00 ","itemcomposition":"250 gms rice +100 gms raita ","isvegetarian":"true","isspecial":"false"},{"itemname":"mini meal (south)","itemdesc":"mini meal (south)","itemprice":" rs. 45.00 ","itemcomposition":"2 chapathi+200grmrice +90ml rasam+90ml sambhar+90ml veg curry","isvegetarian":"true","isspecial":"false"},{"itemname":"south indian meal","itemdesc":"vegetarian. meal","itemprice":" rs. 60.00 ","itemcomposition":"2 chapathi+100grmrice +100grm rice bath+90mlrasam+90grmdry veg preperation+90ml grave veg preperation+90mlsambhar/dal+curd+pappad+sweet","isvegetarian":"true","isspecial":"false"},{"itemname":"north indian veg. meal","itemdesc":"north indian veg. meal","itemprice":" rs. 70.00 ","itemcomposition":"1 chapathi+1 tanduri roti+100 grm biryani +100grm rice+90 ml rasam+90grm veg dry +90ml curry+90 ml dal+curd+pappad+swet","isvegetarian":"true","isspecial":"false"},{"itemname":"north karnataka meal","itemdesc":"plantaian leaf meal","itemprice":" rs. 95.00 ","itemcomposition":"jowa roti+ennagai+kalu pallya+soppu pallya+rice+sambar+bajji+kosambari/chatni+butter milk+curd+salad+sweet","isvegetarian":"true","isspecial":"false"}]},{"foodtypename":"snacks","fooditemdetails":[{"itemname":"idly - 2 nos","itemdesc":"idly - 2 nos","itemprice":" rs. 20.00 ","itemcomposition":"60gms each + 80 ml chutney & 100 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"idly - vada ( 1 idly + vada )","itemdesc":"( 1 idly + vada )","itemprice":" rs. 25.00 ","itemcomposition":"60 gms each piece+ 80 ml chutney & 100 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"idly - vada ( 2 idly + vada )","itemdesc":"( 2 idly + vada )","itemprice":" rs. 35.00 ","itemcomposition":"60 gms each piece+ 80 ml chutney & 100 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"rava idly - 2 nos","itemdesc":"rava idly - 2 nos","itemprice":" rs. 32.00 ","itemcomposition":"60 gms each + 80 ml chutney & 100 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"dosa - plain","itemdesc":"dosa - plain","itemprice":" rs. 25.00 ","itemcomposition":"80 gms + 60 ml chutney & 80 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"dosa","itemdesc":"masala/onion / rawa / ragi / vegetable / wheat /neer /ghee rost","itemprice":" rs. 32.00 ","itemcomposition":"150 gms + 80 ml chutney & 80 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"spl dosa","itemdesc":"ghee masala/rava masala","itemprice":" rs. 37.00 ","itemcomposition":"150 gm + 80 ml chutney & 80 ml sambar","isvegetarian":"true","isspecial":"false"},{"itemname":"dosa - set","itemdesc":"3 no","itemprice":" rs. 32.00 ","itemcomposition":"60 gms each + 80 ml chutney & 100 gms sagu","isvegetarian":"true","isspecial":"false"},{"itemname":"uthappam","itemdesc":"masala / tomato / onion / other","itemprice":" rs. 32.00 ","itemcomposition":"200 gms + 80 ml chutney & 80 ml sagu","isvegetarian":"true","isspecial":"false"},{"itemname":"vada single","itemdesc":"vada","itemprice":" rs. 17.00 ","itemcomposition":"60grms +60 ml chatni+80ml sambar","isvegetarian":"true","isspecial":"true"},{"itemname":"chow chow bath","itemdesc":"chow chow bath","itemprice":" rs. 35.00 ","itemcomposition":"120 gms each of khara & 100 gms kesari + 60 ml chutney","isvegetarian":"true","isspecial":"true"},{"itemname":"khara bath - upma","itemdesc":"khara bath - upma","itemprice":" rs. 20.00 ","itemcomposition":"120 gms + chutney ","isvegetarian":"true","isspecial":"false"},{"itemname":"pongal","itemdesc":"pongal","itemprice":" rs. 30.00 ","itemcomposition":"250 gms + 60 ml chutney + 80 ml raita ","isvegetarian":"true","isspecial":"true"}]}]}]},{"foodcourtname":"foodcourt2","foodcourtdetails":[{"vendorname":"dolphin","vendordetails":[{"foodtypename":"breakfast","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"}]},{"foodtypename":"lunch","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"lassi","itemdesc":"sweet curd","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of sweet lassi","isvegetarian":"true","isspecial":"false"},{"itemname":"amritsari kheer","itemdesc":"rice kheer ","itemprice":" rs. 30.00 ","itemcomposition":"110 ml of rice kheer","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle paranthas","itemdesc":"cholle 3 paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 3 tandoori paranthas (60 grams each)+ raita 85 ml.","isvegetarian":"true","isspecial":"true"},{"itemname":"cholle kulchas","itemdesc":"cholle stuffed 2 aloo kulchas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 2 kulchas (60 grams each)+ salad 85 ml+ imli chutney 80 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle rice ","itemdesc":"cholle, jeera basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams cholle+ 200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"dal rice","itemdesc":"dal, basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams dal+200 grams basmathi rice+ raita 85 ml","isvegetarian":"true","isspecial":"true"},{"itemname":"dal paranthas","itemdesc":"dal, 3 tandoori paranthas","itemprice":" rs. 70.00 ","itemcomposition":"160 grams dal+ 3 tandoori paranthas+ 60 grams salad","isvegetarian":"true","isspecial":"false"},{"itemname":"butter paneer paranthas","itemdesc":"butter paneer gravy, 3 tandoori paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams butter paneer gravy+ 4 pieces of paneer+ 3 tandoori paranthas+ 60 grams salad","isvegetarian":"true","isspecial":"false"},{"itemname":"butter paneer rice","itemdesc":"butter paneer gravy, basmathi jeera rice.","itemprice":" rs. 80.00 ","itemcomposition":"160 grams butter paneer gravy+ 4 pieces of paneer+ 200 grams of basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"kadi pakoda rice","itemdesc":"kadi pakoda, basmathi jeera rice.","itemprice":" rs. 70.00 ","itemcomposition":"160 grams kadi pakoda+200 grams basmathi jeera rice+raita 85 ml.","isvegetarian":"true","isspecial":"false"},{"itemname":"rajma parantha","itemdesc":"rajma ,3 tandoori paranthas","itemprice":" rs. 70.00 ","itemcomposition":"160 rajma+ 3 tandoori paranthas(60 grams each)+60 grams salad","isvegetarian":"true","isspecial":"true"},{"itemname":"rajma rice","itemdesc":"rajma, basmathi jeera rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams rajma+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"butter chicken rice","itemdesc":"butter chicken, 3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"120 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"},{"itemname":"butter chicken paranthas ","itemdesc":"butter chicken, 3 tandoori paranthas ","itemprice":" rs. 90.00 ","itemcomposition":"120 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"true"},{"itemname":"chicken curry paranthas ","itemdesc":"chicken curry,3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"false"},{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]},{"foodtypename":"snacks","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"lassi","itemdesc":"sweet curd","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of sweet lassi","isvegetarian":"true","isspecial":"false"},{"itemname":"amritsari kheer","itemdesc":"rice kheer ","itemprice":" rs. 30.00 ","itemcomposition":"110 ml of rice kheer","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle paranthas","itemdesc":"cholle 3 paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 3 tandoori paranthas (60 grams each)+ raita 85 ml.","isvegetarian":"true","isspecial":"true"},{"itemname":"cholle kulchas","itemdesc":"cholle stuffed 2 aloo kulchas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 2 kulchas (60 grams each)+ salad 85 ml+ imli chutney 80 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle rice ","itemdesc":"cholle, jeera basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams cholle+ 200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"chicken curry paranthas ","itemdesc":"chicken curry,3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"true"},{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]},{"foodtypename":"dinner","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"lassi","itemdesc":"sweet curd","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of sweet lassi","isvegetarian":"true","isspecial":"false"},{"itemname":"amritsari kheer","itemdesc":"rice kheer ","itemprice":" rs. 30.00 ","itemcomposition":"110 ml of rice kheer","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle paranthas","itemdesc":"cholle 3 paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 3 tandoori paranthas (60 grams each)+ raita 85 ml.","isvegetarian":"true","isspecial":"true"},{"itemname":"cholle kulchas","itemdesc":"cholle stuffed 2 aloo kulchas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 2 kulchas (60 grams each)+ salad 85 ml+ imli chutney 80 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle rice ","itemdesc":"cholle, jeera basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams cholle+ 200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"dal rice","itemdesc":"dal, basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams dal+200 grams basmathi rice+ raita 85 ml","isvegetarian":"true","isspecial":"true"},{"itemname":"dal paranthas","itemdesc":"dal, 3 tandoori paranthas","itemprice":" rs. 70.00 ","itemcomposition":"160 grams dal+ 3 tandoori paranthas+ 60 grams salad","isvegetarian":"true","isspecial":"false"},{"itemname":"butter paneer paranthas","itemdesc":"butter paneer gravy, 3 tandoori paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams butter paneer gravy+ 4 pieces of paneer+ 3 tandoori paranthas+ 60 grams salad","isvegetarian":"true","isspecial":"false"},{"itemname":"butter paneer rice","itemdesc":"butter paneer gravy, basmathi jeera rice.","itemprice":" rs. 80.00 ","itemcomposition":"160 grams butter paneer gravy+ 4 pieces of paneer+ 200 grams of basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"kadi pakoda rice","itemdesc":"kadi pakoda, basmathi jeera rice.","itemprice":" rs. 70.00 ","itemcomposition":"160 grams kadi pakoda+200 grams basmathi jeera rice+raita 85 ml.","isvegetarian":"true","isspecial":"false"},{"itemname":"rajma parantha","itemdesc":"rajma ,3 tandoori paranthas","itemprice":" rs. 70.00 ","itemcomposition":"160 rajma+ 3 tandoori paranthas(60 grams each)+60 grams salad","isvegetarian":"true","isspecial":"true"},{"itemname":"rajma rice","itemdesc":"rajma, basmathi jeera rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams rajma+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"butter chicken rice","itemdesc":"butter chicken, 3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"120 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"},{"itemname":"butter chicken paranthas ","itemdesc":"butter chicken, 3 tandoori paranthas ","itemprice":" rs. 90.00 ","itemcomposition":"120 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"true"},{"itemname":"chicken curry paranthas ","itemdesc":"chicken curry,3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"false"},{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]}]}]},{"foodcourtname":"foodcourt3","foodcourtdetails":[{"vendorname":"aathapar","vendordetails":[{"foodtypename":"breakfast","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"lassi","itemdesc":"sweet curd","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of sweet lassi","isvegetarian":"true","isspecial":"false"},{"itemname":"amritsari kheer","itemdesc":"rice kheer ","itemprice":" rs. 30.00 ","itemcomposition":"110 ml of rice kheer","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle paranthas","itemdesc":"cholle 3 paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 3 tandoori paranthas (60 grams each)+ raita 85 ml.","isvegetarian":"true","isspecial":"true"},{"itemname":"cholle kulchas","itemdesc":"cholle stuffed 2 aloo kulchas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 2 kulchas (60 grams each)+ salad 85 ml+ imli chutney 80 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle rice ","itemdesc":"cholle, jeera basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams cholle+ 200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"chicken curry paranthas ","itemdesc":"chicken curry,3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"true"},{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]},{"foodtypename":"lunch","fooditemdetails":[{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]},{"foodtypename":"snacks","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"lassi","itemdesc":"sweet curd","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of sweet lassi","isvegetarian":"true","isspecial":"false"},{"itemname":"amritsari kheer","itemdesc":"rice kheer ","itemprice":" rs. 30.00 ","itemcomposition":"110 ml of rice kheer","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle paranthas","itemdesc":"cholle 3 paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 3 tandoori paranthas (60 grams each)+ raita 85 ml.","isvegetarian":"true","isspecial":"true"},{"itemname":"cholle kulchas","itemdesc":"cholle stuffed 2 aloo kulchas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 2 kulchas (60 grams each)+ salad 85 ml+ imli chutney 80 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle rice ","itemdesc":"cholle, jeera basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams cholle+ 200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"chicken curry paranthas ","itemdesc":"chicken curry,3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"true"},{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]},{"foodtypename":"dinner","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"chicken curry paranthas ","itemdesc":"chicken curry,3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"false"},{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]}]},{"vendorname":"tadka singh","vendordetails":[{"foodtypename":"breakfast","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"lassi","itemdesc":"sweet curd","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of sweet lassi","isvegetarian":"true","isspecial":"false"},{"itemname":"amritsari kheer","itemdesc":"rice kheer ","itemprice":" rs. 30.00 ","itemcomposition":"110 ml of rice kheer","isvegetarian":"true","isspecial":"true"},{"itemname":"cholle paranthas","itemdesc":"cholle 3 paranthas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 3 tandoori paranthas (60 grams each)+ raita 85 ml.","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle kulchas","itemdesc":"cholle stuffed 2 aloo kulchas","itemprice":" rs. 80.00 ","itemcomposition":"160 grams cholle+ 2 kulchas (60 grams each)+ salad 85 ml+ imli chutney 80 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"cholle rice ","itemdesc":"cholle, jeera basmathi rice","itemprice":" rs. 70.00 ","itemcomposition":"160 grams cholle+ 200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"true","isspecial":"false"},{"itemname":"chicken curry paranthas ","itemdesc":"chicken curry,3 tandoori paranthas","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+ 3 tandoori paranthas (60 grams each)+ 60 grams salad","isvegetarian":"false","isspecial":"false"},{"itemname":"chicken curry rice ","itemdesc":"chicken curry, basmathi jeers rice.","itemprice":" rs. 90.00 ","itemcomposition":"130 grams chicken+200 grams basmathi jeera rice+ raita 85 ml","isvegetarian":"false","isspecial":"false"}]},{"foodtypename":"lunch","fooditemdetails":[{"itemname":"masala chaas","itemdesc":"spicy butter milk, cold","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of masala butter milk","isvegetarian":"true","isspecial":"false"},{"itemname":"lassi","itemdesc":"sweet curd","itemprice":" rs. 30.00 ","itemcomposition":"320 ml of sweet lassi","isvegetarian":"true","isspecial":"false"}]}]}]}]'; var app = angular.module('fcapp', []); app.controller('fccontroller', function ($scope) { $scope.fcmenu = eval('(' + fcjson + ')'); });
how should apply filter should able apply filter on items in list (i.e itemname, foodtype, vendor, foodcourt , price?
thanks in advance
create custom filter "myfilter" below: jsfiddle link reference - https://jsfiddle.net/bz5zon4l/#
<div ng-controller="fccontroller"> <div class="control"> <input type="search" ng-model="txtsearch" placeholder="search here" /> </div> <div id="menu"> <div ng-repeat="foodcourt in fcmenu"> <div ng-repeat="vendor in foodcourt.foodcourtdetails"> <div ng-repeat="foodtype in vendor.vendordetails"> <div class="fooditem" ng-repeat="fooddetails in foodtype.fooditemdetails | myfilter:txtsearch:foodtype:vendor:foodcourt"> <div>{{fooddetails.itemname}} - {{foodtype.foodtypename}}</div> <div>{{vendor.vendorname}} - {{foodcourt.foodcourtname}}</div> <div>{{fooddetails.itemprice}}</div> </div> </div> </div> </div> </div> </div> app.filter('myfilter', function() { return function(item, textsearch, foodtype, vendor, foodcourt) { var result = []; if (textsearch && item && foodtype && vendor && foodcourt) { (var = 0; < item.length; i++) { var tempsearch = item[i].itemname + foodtype.foodtypename + vendor.vendorname + foodcourt.foodcourtname + item[i].itemprice; if (tempsearch) { var searchindex = tempsearch.tolowercase().search(textsearch.tolowercase()); if (searchindex >= 0) { result.push(item[i]); tempsearch = ''; } } } return result; } return item; } });
Comments
Post a Comment