对于选择不调用声明的方法角度NG-变化 [英] Angular ng-change for select not calling the declared method
本文介绍了对于选择不调用声明的方法角度NG-变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下的HTML表单的SELECT语句
I have the following html form select statement
<select ng-change="setBillGroup()" ng-model="bill.groupId" class="span8" ng-options="d.id as d.name for d in groups"></select>
和JS的
myApp.controller('myAppController', function($scope, myAppService) {
.....
function setBillGroup(){
console.log("setBillGroup method called!");
......
}
....
});
但由于某些原因,setBillGroup()似乎从来没有被调用时,我选择的形式的东西或其他。
But for some reason the setBillGroup() never seems to get called when I select something or the other in the form.
推荐答案
您必须定义范围的方法。
You have to define the method in the scope.
$scope.setBillGroup = function(){
console.log("setBillGroup method called!");
......
};
这篇关于对于选择不调用声明的方法角度NG-变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文