Angular的ng-change for select不调用声明的方法

Angular ng-change for select not calling the declared method

本文关键字:调用 声明 方法 select ng-change for Angular      更新时间:2023-09-26

我有以下html表单select语句

<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()似乎从来没有被调用,当我选择一些东西或其他形式

您必须在作用域中定义该方法。

$scope.setBillGroup = function(){
 console.log("setBillGroup method called!");
    ......
 };