Javascript Angularjs-重复并单击
我试着做一个angularjs项目。我有以下代码: HTML: 列表按预期生成,但当我单击其中一个元素时,会收到以下错误消息:Javascript Angularjs-重复并单击,javascript,angularjs,Javascript,Angularjs,我试着做一个angularjs项目。我有以下代码: HTML: 列表按预期生成,但当我单击其中一个元素时,会收到以下错误消息: Error: fnPtr is not a function Parser.prototype.functionCall/<@http://localhost:8000/app2/lib/angular/angular.js:10169 ngEventDirectives[directiveName]</<.compile/</</<
Error: fnPtr is not a function Parser.prototype.functionCall/<@http://localhost:8000/app2/lib/angular/angular.js:10169 ngEventDirectives[directiveName]</<.compile/</</<@http://localhost:8000/app2/lib/angular/angular.js:17823 Scope.prototype.$eval@http://localhost:8000/app2/lib/angular/angular.js:11906 Scope.prototype.$apply@http://localhost:8000/app2/lib/angular/angular.js:12006 ngEventDirectives[directiveName]</<.compile/</<@http://localhost:8000/app2/lib/angular/angular.js:17822 createEventHandler/eventHandler/<@http://localhost:8000/app2/lib/angular/angular.js:2610 forEach@http://localhost:8000/app2/lib/angular/angular.js:309 createEventHandler/eventHandler@http://localhost:8000/app2/lib/angular/angular.js:2609
错误:fnPtr不是函数解析器。prototype.functionCall/您应该为函数$scope.answer使用其他名称
$scope.answer1 = function(ans) {
console.log('clicked' + ans);
}
HTML:
-
{{answer}}({{$index}})
OMG。我是如此愚蠢和盲目:D.有时你需要另一双眼睛。@Leftjustized,是的,伙计,我们有时都会犯一些愚蠢的错误,所以给你额外的(一双眼睛)*看,享受吧
Error: fnPtr is not a function Parser.prototype.functionCall/<@http://localhost:8000/app2/lib/angular/angular.js:10169 ngEventDirectives[directiveName]</<.compile/</</<@http://localhost:8000/app2/lib/angular/angular.js:17823 Scope.prototype.$eval@http://localhost:8000/app2/lib/angular/angular.js:11906 Scope.prototype.$apply@http://localhost:8000/app2/lib/angular/angular.js:12006 ngEventDirectives[directiveName]</<.compile/</<@http://localhost:8000/app2/lib/angular/angular.js:17822 createEventHandler/eventHandler/<@http://localhost:8000/app2/lib/angular/angular.js:2610 forEach@http://localhost:8000/app2/lib/angular/angular.js:309 createEventHandler/eventHandler@http://localhost:8000/app2/lib/angular/angular.js:2609
$scope.answer1 = function(ans) {
console.log('clicked' + ans);
}
<ul>
<li ng-repeat="answer in question.answers">
<button type="button" ng-click="answer1($index)">{{answer}} ({{$index}})</button>
</li>
</ul>