Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular ng-change for select not calling the declared method

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>

and the js

myApp.controller('myAppController', function($scope, myAppService) {

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

....
});

But for some reason the setBillGroup() never seems to get called when I select something or the other in the form.

like image 580
user6123723 Avatar asked Jun 08 '13 23:06

user6123723


1 Answers

You have to define the method in the scope.

$scope.setBillGroup = function(){
 console.log("setBillGroup method called!");
    ......
 };
like image 194
Ufuk Hacıoğulları Avatar answered Oct 18 '22 19:10

Ufuk Hacıoğulları