Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Arrays 将angular.forEach/if语句清理成更简洁的代码?_Arrays_Angularjs_Foreach - Fatal编程技术网

Arrays 将angular.forEach/if语句清理成更简洁的代码?

Arrays 将angular.forEach/if语句清理成更简洁的代码?,arrays,angularjs,foreach,Arrays,Angularjs,Foreach,我得到了我想要的结果——但我正在用一种方式,哇。 我一直在数组中查找正确的数组,然后执行foreach和if以查找下一个正确的数组。有没有更卫生的方法?我的代码如下: angular.forEach($scope.bitrates, function(bitrateset) { if(bitrateset.resolution == cam.camera.resolution){ angular.forEach(bitrateset.stats, fu

我得到了我想要的结果——但我正在用一种方式,哇。 我一直在数组中查找正确的数组,然后执行foreach和if以查找下一个正确的数组。有没有更卫生的方法?我的代码如下:

 angular.forEach($scope.bitrates, function(bitrateset) {
         if(bitrateset.resolution == cam.camera.resolution){
            angular.forEach(bitrateset.stats, function(stat) {
                if(stat.activity == cam.activity){
                    angular.forEach(stat.fps, function(fps) {
                        angular.forEach(fps.range, function(range) {
                        if(range == cam.fps){
                            cam.bitrate = fps.bitrate;
                        }
                        else{
                        }
                    });
                });
                }
         });
         }
    });

你能附上一个比特率数组的例子吗?你能换成dict/object吗?通常情况下,当您想要进行直接查找时,效果会更好