剛剛接觸到angularjs。我試圖用角服務發佈的數據,但下面的錯誤注入服務到控制器不能正常工作
angular.js其投擲:12520錯誤:[$注射器:unpr]未知提供商:frontendServiceddProvider < - frontendServicedd < - CustSignupCtrl
service.js
app.service('frontendService', function frontendService ($http, $q, $rootScope){
var list = this;
list.registerCust = function(data){
var defer = $q.defer();
$http({
url: $rootScope.endPoint,
method: "POST",
data: data
})
.success(function(res){
console.log("Successfull!");
defer.resolve(res);
})
.error(function(err, status){
console.log("Failed !");
})
return defer.promise;
}
return list;
});
customer_signup.js
app.controller('CustSignupCtrl', ['$scope', '$filter','frontendService', '$http', 'editableOptions', 'editableThemes','notify','notification','$appConstants',
function('$scope', '$filter','frontendService', '$http','editableOptions', 'editableThemes','notify','notification','$appConstants'){
$scope.pw1 = '';
$scope.registerCustomer = function (data) {
return frontendService.registerCust(data)
}
$scope.signupcustomer = function(){
var payload= {
first_name: $scope.custForm.fname,
last_name: $scope.custForm.lname,
phone: $scope.custForm.phone,
email:$scope.custForm.email,
username:$scope.custForm.username,
password:$scope.custForm.pw1,
usertype:3
}
console.log("inside function");
$scope.registerCustomer(payload).then(function(data){
notification.success(data.result);
},function(err){
notification.error("Error: contact system admin");
});
}
}
])
我給的參考這兩個JS文件index.html中..沒有得到哪裏做錯了..任何人都可以幫助
您的注射不正確。變量應該是類似的 '$ scope','frontendService','$ filter','$ http','editableOptions','editableThemes','notify','notification','$ appConstants'。 您的函數參數在控制器函數 –