使用angularjs观察下拉列表的选定值以填充数组取决于所选值 [英] watch the selected value of dropdown with angularjs to populate an array depends on the selected value

查看:61
本文介绍了使用angularjs观察下拉列表的选定值以填充数组取决于所选值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个小提琴 http://jsfiddle.net/sheko_elanteko/Anj3w/9/ [ ^ ]



我想检查模型sectionSelect的选定值,并根据所选的值,将它设置为1或2,我想用新的值填充newArr,按顺序排列相应地过滤最低和最高价格。



我现在正在做的是......



I have this fiddle http://jsfiddle.net/sheko_elanteko/Anj3w/9/[^]

I want to check for the selected value of the model "sectionSelect", and based on the selected value, weather it's "1" or "2", I want to fill the newArr with the new values that match the selected, in order to filter the min and max prices accordingly.

What I'm doing right now is this ...

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 that doesn't seem to work.
What should I do?

推荐答案

scope.sectionSelect == 1 ){

for
scope.sectionSelect == 1) { for(


i = 0 ;


i< arr.length;
i < arr.length;


这篇关于使用angularjs观察下拉列表的选定值以填充数组取决于所选值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆