3
Answers

How to add new empty row on dropdown change using angular

by using below code am adding new row on dropdown change,
if select option 'madhu' in dropdown ,adding new row with same selected madhu .if i select any dropdown madhu,all values are changing to madhu
how to fix this, iwant to add new empty row on dropdown change
<tr ng-repeat="r in rvm">
<td>
<select ng-model="customer.ID" ng-change="GetAccountBalance($index)" ng-options="c.ID as c.Name for c in customer" name="tCustomer">
<option value="">select Customer</option>
</select>
</td>
<td>
<select ng-model="ReceiptsViewModel.AccountId" ng-options="a.ID as a.Name for a in account" name="tDiscountAcc1" style="width:150px;height:22px;">
<option value="">Select Account</option>
</select>
</td>
<td>
<input type="text" ng-value="0.00" ng-model="ReceiptsViewModel.AdjustAmount" ng-change="GetTotalAmount()" class="input-large" name="tAdjustAmount" />
</td>
</tr>
js
$scope.rvm = [{}];
$scope.GetAccountBalance = function (index) {
var getAccountBalance = ReceiptsService.GetAccountBalance($scope.customer.ID);
var id = $scope.customer.ID;
alert(id);
if ($scope.rvm.length == (index + 1)) {
$scope.rvm.push({
});
}

Answers (3)