我正在更新我的问题,我在angularjs中运行代码时出现问题,控制器注入错误即将到来。它是一个从数据库中检索值的服务。我有一个json,它提供了我的json值,但我发现在我的控制器中使用json的映射值有点困难,请有人在这个问题上帮助我。感谢
码
(function(){
'use strict';
angular.module('app').controller('preAuthMinDraftController',preAuthMinDraftController);
preAuthMinDraftController.$inject=['$http','$scope','preAuthMinDraftService'];
function preAuthMinDraftController($http, $scope, preAuthMinDraftService)
{
$scope.getMinValue = function(minValue){
alert("getMIN Controller");
$scope.StatusType = "DRAFT";
$scope.ResultType ="MIN";
preAuthMinDraftService.getMin($scope.StatusType,$scope.ResultType).then(function(response) {
if(response.result==true){
$scope.minValue = response.collections;
console.log($scope.minValue);
}else{
console.log("Error");
}
},
function(error){
console.log("Error");
});
$scope.minValue.collection = {};
$scope.minValue.collections.preAuthDashboardVO = {};
$scope.minValue.collections.preAuthDashboardVO.patientName = patientName;
$scope.minValue.collections.preAuthDashboardVO.policyNumber = policyNumber;
$scope.minValue.collections.preAuthDashboardVO.payer = payer;
$scope.minValue.collections.preAuthDashboardVO.tpaMemberId = tpaMemberId;
$scope.minValue.collections.preAuthDashboardVO.createdDate = createdDate;
$scope.minValue.collections.preAuthDashboardVO.preAuthClaimId = preAuthClaimId;
$scope.minValue.collections.preAuthDashboardVO.preauthClaimIdentifier = preauthClaimIdentifier;
}
}})();
服务
(function () {
'use strict';
angular
.module('app')
.factory('preAuthMinDraftService', preAuthMinDraftService);
preAuthMinDraftService.$inject = ['$http', '$cookieStore', '$rootScope', '$timeout','$q'];
function preAuthMinDraftService($http, $cookieStore, $rootScope, $timeout,$q) {
this.getMin=function(StatusType,ResultType)
{
alert("service");
var deferred = $q.defer();
var request = $http({
method : 'POST',
url : getMinURL,
headers :{authToken:$rootScope.authToken},
data :{"StatusType":StatusType,"ResultType":ResultType}
});
request.success(function(data) {
deferred.resolve(data);
}).error(function(error) {
deferred.reject(error);
});
return deferred.promise;
};
这些是我已经映射的json
$scope.minValue.collection = {};
$scope.minValue.collections.preAuthDashboardVO = {};
$scope.minValue.collections.preAuthDashboardVO.patientName = patientName;
$scope.minValue.collections.preAuthDashboardVO.policyNumber = policyNumber;
$scope.minValue.collections.preAuthDashboardVO.payer = payer;
$scope.minValue.collections.preAuthDashboardVO.tpaMemberId = tpaMemberId;
$scope.minValue.collections.preAuthDashboardVO.createdDate = createdDate;
$scope.minValue.collections.preAuthDashboardVO.preAuthClaimId = preAuthClaimId;
$scope.minValue.collections.preAuthDashboardVO.preauthClaimIdentifier = preauthClaimIdentifier;
控制台错误
preAuthMinDraftController.js:80 Uncaught SyntaxError: Unexpected token )
jquery.min.js:4 GET http://localhost/claimbook/assets/js/momnet.min.js attr @ jquery.min.js:4n.access @ jquery.min.js:2attr @ jquery.min.js:3$set @ angular.js:5830(anonymous function) @ angular.js:15978(anonymous function) @ angular.js:5873$eval @ angular.js:12608$digest @ angular.js:12420$apply @ angular.js:12712(anonymous function) @ angular.js:1419invoke @ angular.js:3918doBootstrap @ angular.js:1417bootstrap @ angular.js:1431angularInit @ angular.js:1344(anonymous function) @ angular.js:21817j @ jquery.min.js:2fireWith @ jquery.min.js:2ready @ jquery.min.js:2I @ jquery.min.js:2
jquery.min.js:4 GET http://localhost/claimbook/assets/js/bootstra.datetimepicker.min.js attr @ jquery.min.js:4n.access @ jquery.min.js:2attr @ jquery.min.js:3$set @ angular.js:5830(anonymous function) @ angular.js:15978(anonymous function) @ angular.js:5873$eval @ angular.js:12608$digest @ angular.js:12420$apply @ angular.js:12712(anonymous function) @ angular.js:1419invoke @ angular.js:3918doBootstrap @ angular.js:1417bootstrap @ angular.js:1431angularInit @ angular.js:1344(anonymous function) @ angular.js:21817j @ jquery.min.js:2fireWith @ jquery.min.js:2ready @ jquery.min.js:2I @ jquery.min.js:2
angular.js:9997 Error: [ng:areq] Argument 'preAuthMinDraftController' is not a function, got undefined
http://errors.angularjs.org/1.2.20/ng/areq?p0=preAuthMinDraftController&p1=not%20aNaNunction%2C%20got%20undefined
at http://localhost/claimbook/js/angular.js:78:12
at assertArg (http://localhost/claimbook/js/angular.js:1481:11)
at assertArgFn (http://localhost/claimbook/js/angular.js:1491:3)
at http://localhost/claimbook/js/angular.js:7213:9
at link (http://localhost/claimbook/js/angular-route.js:913:26)
at nodeLinkFn (http://localhost/claimbook/js/angular.js:6648:13)
at compositeLinkFn (http://localhost/claimbook/js/angular.js:6039:13)
at publicLinkFn (http://localhost/claimbook/js/angular.js:5934:30)
at boundTranscludeFn (http://localhost/claimbook/js/angular.js:6059:21)
at controllersBoundTransclude (http://localhost/claimbook/js/angular.js:6669:18)(anonymous function) @ angular.js:9997(anonymous function) @ angular.js:7299nodeLinkFn @ angular.js:6651compositeLinkFn @ angular.js:6039publicLinkFn @ angular.js:5934boundTranscludeFn @ angular.js:6059controllersBoundTransclude @ angular.js:6669update @ angular-route.js:871$broadcast @ angular.js:12887(anonymous function) @ angular-route.js:552wrappedCallback @ angular.js:11498wrappedCallback @ angular.js:11498(anonymous function) @ angular.js:11584$eval @ angular.js:12608$digest @ angular.js:12420$apply @ angular.js:12712done @ angular.js:8315completeRequest @ angular.js:8527xhr.onreadystatechange @ angular.js:8466
custom.js:20 Uncaught TypeError: $(...).datetimepicker is not a function(anonymous function) @ custom.js:20
答案 0 :(得分:0)
您有语法错误,只需要在结束函数声明中取出括号。为了便于阅读,我删除了评论。
function preAuthMinDraftController($scope,$rootScope,$location, AuthenticationService,preAuthMinDraftService) {
$scope.getMinValue=function() {
console.log("test");
$scope.StatusType = "DRAFT";
$scope.ResultType ="MIN";
preAuthMinDraftService.getMin($scope.StatusType,$scope.ResultType, function (response) {
console.log(response);
});
};
}