gpt4 book ai didi

javascript - AngularJS 错误 : fnPtr is not a function

转载 作者:IT老高 更新时间:2023-10-28 13:50:25 25 4
gpt4 key购买 nike

我正在尝试编写一个示例 AngularJS 和 SpringMVC 项目。 spring 方法工作正常,但我的站点 Controller 中的函数声明存在问题。我的应用程序应该从文本输入中返回一个单词,但是当我单击按钮时,出现此错误:

[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>

还有controler.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 工作正常,但是当我单击按钮时它崩溃了。

最佳答案

只是想为收到此错误的任何人添加,如果您像我一样犯了创建与函数同名的变量的 n00b 错误(从 ng-click 调用的函数:

p>
$scope.addTask = {};

$scope.addTask = function() {};

关于javascript - AngularJS 错误 : fnPtr is not a function,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19208518/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com