对于选择不调用声明的方法角度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!");
    ......
 };