js文件1
var loginApp = angular.module("loginApp", ["loginService"]);
js文件2
loginApp.controller("loginValidate", ["$scope", "$params","loginRequestService",function ($scope, $params, loginRequestService) {
$scope.LoginCheck = function (params, isValid) {
if (isValid) {
angular.element(".alert alert-error hide").show();
angular.element(".alertError").html("请输入用户名和密码")
$scope.sName = true;
}
else {
$scope.sName = true;
}
params = {
"username":$scope.username,
"password":$scope.password
}
loginRequestService.login(params).success(function (response) {
var result = angular.fromJson(response.result);
if (result.IsSuccess == false) {
angular.element(".alert alert-error hide").show()
angular.element(".alertError").html(result.Message);
$scope.sName = true;
}
})
}
}])
js文件3
//服务
var loginService = angular.module("loginService",[]);
//请求服务
loginService.factory("loginRequestService", ["$http",function ($http) {
//请求参数
var requestParams = {
method: "",
url:"",
headers:{},
params:{}
};
//$http({requst})
var requst = {
login:function (data) {
requestParams.method = "get";
requestParams.url = "http://localhost:30456/api/login";
requestParams.headers = { "content-type":"application/json" }
requestParams.params = response;
RequestService($http, requestParams);
},
};
}]);
//请求服务
function RequestService($http, request) {
var result = $http(request);
return result;
}
为什么一直提示 Error: [$injector:unpr]。。。。求解答