0
當試圖做到這一點:angularjs類型錯誤:布爾不是一個函數NG單擊多個動作
<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點擊= 「doAllThisStuff($指數)」' –