[SPRING] AngularJS 오류 : fnPtr은 함수가 아닙니다.
SPRINGAngularJS 오류 : fnPtr은 함수가 아닙니다.
샘플 AngularJS 및 SpringMVC 프로젝트를 작성하려고합니다. 스프링 메서드는 잘 작동하지만 내 사이트 컨트롤러의 함수 선언에 문제가 있습니다. 내 애플 리케이션은 텍스트 입력에서 단어를 반환해야하지만, 버튼을 클릭하면, 나는이 오류가있어 :
[13:23:58.900] "Error: fnPtr is not a function
parser/_functionCall/<@http://localhost:8080/example/resources/js/Angular/angular.js:6542
ngEventDirectives[directiveName]</</</<@http://localhost:8080/example/resources/js/Angular/angular.js:13256
Scope.prototype.$eval@http://localhost:8080/example/resources/js/Angular/angular.js:8218
Scope.prototype.$apply@http://localhost:8080/example/resources/js/Angular/angular.js:8298
ngEventDirectives[directiveName]</</<@http://localhost:8080/example/resources/js/Angular/angular.js:13255
createEventHandler/eventHandler/<@http://localhost:8080/example/resources/js/Angular/angular.js:2095
forEach@http://localhost:8080/example/resources/js/Angular/angular.js:130
createEventHandler/eventHandler@http://localhost:8080/example/resources/js/Angular/angular.js:2094
"
이것은 내 index.html입니다 :
<!DOCTYPE html>
<html lang="en" ng-app="Apken">
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="resources/js/Angular/angular.js"></script>
<script src="resources/js/controler.js"></script>
</head>
<body ng-controller="theNamer">
<div class="input-append">
<input style="width:358px;" class="span2" type="text" ng-model="myName" required min="1" />
<button class="btn btn-primary" ng-disabled="!myName" ng-click="send()">Click!</button>
</div>
<ul>
<li ng-repeat="name in names">{{name}}</li>
</ul>
</body>
</html>
그리고 controller.js :
function theNamer ($scope,$http){
$scope.myName='aa';
$scope.fetchList=new function()
{
$http.get('ca/list.json').success(function(thList){
$scope.names = thList;
});
}
$scope.send=new function()
{
$http.post('ca/set/3').success(function(){
$scope.fetchList;
});
}
$scope.fetchList;
}
var Apken = angular.module('Apken',[]);
Apken.controller('theNamer', theNamer);
나는 그것이 ng-click 값에서 함수 선언과 관련하여 어떤 종류의 문제 여야 만한다는 것을 알았다. 사이트 시작시 controler.js는 정상적으로 작동하지만 버튼을 클릭하면 충돌이 발생합니다.
해결법
-
==============================
1.나는 당신의 코드를 테스트했다. AngularJS 1.0.7을 사용하면 대체 할 때 오류가 사라집니다.
나는 당신의 코드를 테스트했다. AngularJS 1.0.7을 사용하면 대체 할 때 오류가 사라집니다.
$scope.send = new function() {
와
$scope.send = function () {
fetchList에도 동일하게 적용됩니다.
(* args *) {* body *}와 새로운 Function (* args *, * body *) 구문을 혼합했다고 생각합니다. MDN : 기능을 확인하십시오.
fetchList를 제대로 호출 할 수 있도록 코드를 변경해야합니다.
function theNamer($scope, $http) { $scope.myName = 'aa'; $scope.fetchList = function() { $http.get('ca/list.json').success(function(thList) { $scope.names = thList; }); }; $scope.send = function() { $http.post('ca/set/3').success(function() { $scope.fetchList(); }); }; $scope.fetchList(); }
-
==============================
2.이 오류를받는 사람을 추가하기를 원했을 때, 나처럼, 함수와 동일한 이름을 가진 변수를 만드는 n00b 실수를 저지르는 경우 (ng-click에서 호출되는 함수 :
이 오류를받는 사람을 추가하기를 원했을 때, 나처럼, 함수와 동일한 이름을 가진 변수를 만드는 n00b 실수를 저지르는 경우 (ng-click에서 호출되는 함수 :
$scope.addTask = {}; $scope.addTask = function() {};
from https://stackoverflow.com/questions/19208518/angularjs-error-fnptr-is-not-a-function by cc-by-sa and MIT license
'SPRING' 카테고리의 다른 글
[SPRING] 두 개의 항아리 사이의 Spring Boot 및 @ComponentScan (0) | 2019.02.10 |
---|---|
[SPRING] 봄, 요청 방법 'POST'가 지원되지 않음 [닫힘] (0) | 2019.02.10 |
[SPRING] 다중 arg 메소드를 이용한 스프링 빈 초기화 (0) | 2019.02.09 |
[SPRING] Spring 빈 컨텍스트에서 객체의 배열 선언하기 (0) | 2019.02.09 |
[SPRING] 오류 : org.springframework.web.HttpMediaTypeNotSupportedException : 'text / plain; charset = UTF-8'콘텐츠 유형이 지원되지 않습니다. (0) | 2019.02.09 |