suman goud

suman goud

  • NA
  • 176
  • 54.2k

How to get dropdown selected id on ng-repeat in angular

Sep 19 2016 2:20 AM
by using this code am able to get dropdown id(if i comment ng-repeat)
 
<tr @*ng-repeat="r in rvm"*@ @*>
<td>
<select ng-model="ID" ng-options="c.ID as c.Name for c in customer" ng-change="GetAccountBalance($index)" style="width:150px;height:22px;" name=" tCustomer">
<option value="">Select Customer</option>
</select>
 
 
js
$scope.GetAccountBalance = function (index) {
var getAccountBalance = ReceiptsService.GetAccountBalance($scope.ID);
var id = $scope.ID;
alert(id);
 
but my requirement is adding new row on dropdown change 
 
<tr ng-repeat="r in rvm">
<td>
<select ng-model="ID" ng-options="c.ID as c.Name for c in customer" ng-change="GetAccountBalance($index)" style="width:150px;height:22px;" name=" tCustomer">
<option value="">Select Customer</option>
</select>
 js
 
$scope.rvm = [{}];
$scope.GetAccountBalance = function (index) {
if ($scope.rvm.length == (index + 1)) {
$scope.rvm.push({
});
}
var getAccountBalance = ReceiptsService.GetAccountBalance($scope.ID);
var id = $scope.ID;
alert(id);
 
 
 
am able to add new row by using this code , but am not getting selected id
how to selected dropdown id,
if i remove ng repeat am getting id , 
 
 
 

Answers (3)