angularjs typeError: boolean is not a function ng-click multiple actions
angularjs typeError: boolean is not a function ng-click multiple actions
尝试实现此目的时:
<li class="answer"><a href="javascript:void(0)" ng-class="answer.show[$index] ? 'selected' : ''" ng-click="(answer.Questions.length > 0) ? (answer.show[$index]=!answer.show[$index]) (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)">{{answer.Description}}</a></li>
TypeError: boolean is not a function
at $parseFunctionCall (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:12333:15)
at $parseTernary (http://localhost//assets/scripts/vendor/bower_components/angular/angular.js:12185:39)
at ngEventDirectives.(anonymous function).compile.element.on.callback (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:22949:17)
at Scope.$get.Scope.$eval (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:14383:28)
at Scope.$get.Scope.$apply (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:14482:23)
at HTMLAnchorElement.<anonymous> (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:22954:23)
at HTMLAnchorElement.eventHandler (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:3011:21)angular.js:11594 (anonymous function)angular.js:8544 $getangular.js:14484 $get.Scope.$applyangular.js:22954 (anonymous function)angular.js:3011 eventHandler
The problem is on my ng-click:
(answer.Questions.length > 0) ? (answer.show[$index]=!answer.show[$index]) (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)
这个应该怎么写才正确?
如果没有必要,我不会在您的视图中放那么多东西。创建一个函数并传递您需要的东西并从那里进行评估。
此外,
ng-click="(answer.Questions.length > 0) ? (answer.show[$index]=!answer.show[$index]) (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)"
这看起来像一个错误的三元运算,如果这是你想要做的?
如果我理解正确的话:
if answer.Questions.length > 0,则 (setAnswer(question, answer.ID)),如果不是 setAnswer(question, answer.ID)。
这部分是做什么用的
(answer.show[$index]=!answer.show[$index])
?
也许你想要这样的东西
((answer.Questions.length > 0) && (answer.show[$index]=!answer.show[$index])) ? (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)
尝试实现此目的时:
<li class="answer"><a href="javascript:void(0)" ng-class="answer.show[$index] ? 'selected' : ''" ng-click="(answer.Questions.length > 0) ? (answer.show[$index]=!answer.show[$index]) (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)">{{answer.Description}}</a></li>
TypeError: boolean is not a function
at $parseFunctionCall (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:12333:15)
at $parseTernary (http://localhost//assets/scripts/vendor/bower_components/angular/angular.js:12185:39)
at ngEventDirectives.(anonymous function).compile.element.on.callback (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:22949:17)
at Scope.$get.Scope.$eval (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:14383:28)
at Scope.$get.Scope.$apply (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:14482:23)
at HTMLAnchorElement.<anonymous> (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:22954:23)
at HTMLAnchorElement.eventHandler (http://localhost/assets/scripts/vendor/bower_components/angular/angular.js:3011:21)angular.js:11594 (anonymous function)angular.js:8544 $getangular.js:14484 $get.Scope.$applyangular.js:22954 (anonymous function)angular.js:3011 eventHandler
The problem is on my ng-click:
(answer.Questions.length > 0) ? (answer.show[$index]=!answer.show[$index]) (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)
这个应该怎么写才正确?
如果没有必要,我不会在您的视图中放那么多东西。创建一个函数并传递您需要的东西并从那里进行评估。
此外,
ng-click="(answer.Questions.length > 0) ? (answer.show[$index]=!answer.show[$index]) (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)"
这看起来像一个错误的三元运算,如果这是你想要做的?
如果我理解正确的话:
if answer.Questions.length > 0,则 (setAnswer(question, answer.ID)),如果不是 setAnswer(question, answer.ID)。
这部分是做什么用的
(answer.show[$index]=!answer.show[$index])
?
也许你想要这样的东西
((answer.Questions.length > 0) && (answer.show[$index]=!answer.show[$index])) ? (setAnswer(question, answer.ID)) : setAnswer(question, answer.ID)