I have a dropdown (Select, option), and the options get populated dynamically using ng-repeat
. I want to call a function within $scope
on change of the option. Here is the HTML
<div class=type-style ng-show=accountCount > 3>
<select class=account-filter>
<option ng-repeat=account in getCustomerName() track by $index ng-class=(account | limitTo: 18) ng-bind=account.split('|')[0]></option>
</select>
</div>
I know we can use ng-change
, but ng-change
needs ng-model
and I don't think ng-model
is needed in my case. Can anyone help?
As you can notice in the code, I am doing and ng-repeat on option tag. So will I get that 'account' which I have used in ng-repeat, in the select tag? So that I can use it in ng-model?
Also, each account is a string that has 3 values separated by a '|'. When I call a function on ng-change, I want to pass the 2nd value with it.
For eg: Each account has Name | number | number2. Now in ng-repeat I am just showing name, as you can see I have done a split in ng-bind. So if I use ng-model in select tag, I will just get name. But I want number to be passed as parameter in the function.