Angular:我如何在工厂中定义烤箱并在Controller中调用它

时间:2014-12-03 07:28:48

标签: angularjs

这是我的工厂

myApp.factory('newBranchRequestFactory', ['$http', function ($http) {

    var newBranchRequestFactory = {};
    var urlBase = '/api/MyAPI/';
    newBranchRequestFactory.SaveRequester = function (requester) {

        $http.post('/api/MyAPI/SaveRequester', requester);
    }
}  

控制器

myApp.controller('newBranchRequestController', ['$scope', 'newBranchRequestFactory', function ($scope, newBranchRequestFactory, toaster) {

 $scope.SaveRequester = function (  Requester )
    {

        newBranchRequestFactory.SaveRequester(Requester);
        toaster.pop('success', "title", "text");
    }  
}

如何在运行SaveRequester功能后显示烤面包机?

1 个答案:

答案 0 :(得分:0)

您正在使用数组的详细注入模型,但数组中注入的参数数量与函数的参数数量不匹配。

要么只使用

等功能定义
.controller('name', function(inject1, inject2){})

或在阵列中添加'烤面包机'匹配你的控制器功能参数。