控制器:
app.controller('searchCtrl', function($scope,$rootScope,$http,$q){
$scope.search = function( values , type) {
if($scope.abort) {
$scope.abort.resolve();
}
$scope.abort = $q.defer();
var data={};
data.values=values;
data.type=type;
$http.post("search.php", data,{timeout:$scope.abort.promise}).then(function success (response) {
$rootScope.search_result=response.data;
},function error (response){
console.log("Request cancelled");
}
);
};
});
但我想检查列表中的一个数组项是否具有属性 val!=""; 除了像这样的循环还有什么方法可以检查它
var flag=0;
for(var i=0; i<values.length; i++){
if(values[i].val!="") flag=1;
}
if(flag)$http...
?