AngularJs ServiceMethod具有更多参数

时间:2014-01-10 09:24:38

标签: angularjs angularjs-scope

在我的控制器中我有这个方法:        ..............

     angular.extend($scope.criteria, $scope.items);  
            angular.extend($scope.criteriaList, $scope.itemsUpdate); 
            console.log('scope %O: ' ,$scope.criteria);
            console.log('scope_ %O: ' ,$scope.criteriaList);
            updateList.getItems($scope.criteria,$scope.criteriaList, function(data){
                 });


and in my service I did this:

      amServices.factory('updateList', [ function() {               
      var updateList= new function(){};
    updateList.getItems = function( items, itemsUpdate,callback){
        console.log('itemsUpdat e%O ' , itemsUpdate);

                  callback(itemsList);   

}

return updateList 
             });

但我无法打印结果..

你知道为什么吗?

1 个答案:

答案 0 :(得分:0)

你的var updateList应该是一个函数数组,而不是函数本身。如下所示

amServices.factory('updateList', [ function() {               
      var updateList= {};
    updateList.getItems = function( items, itemsUpdate,callback){
        console.log('itemsUpdat e%O ' , itemsUpdate);

                  callback(itemsList);   

}

return updateList 
             });