javascript - watch the selected value of dropdown with angularjs to populate an array depends on the selected value -
i have fiddle here
i want check selected value of model "sectionselect", , based on selected value, weather it's "1" or "2", want fill newarr new values match selected, in order filter min , max prices accordingly.
what i'm doing right ...
if ($scope.sectionselect == 1) { for($i=0; $i < arr.length; $i++){ if(arr[$i]['section'] === 1) { newarr.push(arr[$i]['value']); } } } else if($scope.sectionselect == 2) { for($i=0; $i < arr.length; $i++){ if(arr[$i]['section'] === 2) { newarr.push(arr[$i]['value']); } } } but doesn't seem work. should do?
this have , it's working http://jsfiddle.net/sheko_elanteko/anj3w/26/ want add together filter functionality it.
the easiest way filter things using angular utilize built in filtering capabilities. updated fiddle here: http://jsfiddle.net/cqyta/
the changes html utilize dropdowns set scope values selected. these values can used filters (in instance, i'm filtering min , max values based on section selected).
<select ng-model="sectionselect" ng-options="section.label section in sections" ng-change="clearminmax()"> </select> <select ng-model="minval" ng-options="item.value item in app_data | filter:sectionselect.section | orderby:'value'"> <option value="">min price</option> </select> <select ng-model="maxval" ng-options="item.value item in app_data | filter: sectionselect.section | orderby:'-value'"> <option value="">max price</option> </select> based on selected in dropdowns, can these utilize of filter should show up. minmax function in controller, checks whether value between min & max.
<div ng-repeat="item in app_data | filter:sectionselect.section | filter:minmax | orderby:'value'"> {{item.value}} </div> let me know if have questions!
javascript angularjs select filter
No comments:
Post a Comment