suman goud

suman goud

  • NA
  • 176
  • 13.9k

How to remove row on button click in angular js

Sep 27 2016 2:11 AM
am adding new row on clicking Plus(+),
i want to show Minus (-) to previous row ,if i click i want to delete that
particular row ,and continuosly for new row + , and for all previous row i want to show -(glypicon)
 
 
<div ng-app="ReceiptsApp">
<div ng-controller="ReceiptsController">
<table class="tableData">
<tr ng-repeat="r in rvm">
<td>
<select ng-model="c" style="width:150px;height:22px;" ng-options="c.name for c in sample">
<option value="">--Select--</option>
</select>
</td>
<td>
<input type="text" lass="input-large" ng-model="c.Address" name="Address" />
</td>
<td>
<input type="text" class="input-large" ng-model="c.Mobile" name="Mobile" />
</td>
<td>
<a href="#">
<span class="glyphicon glyphicon-plus" ng-click="addRow($index,c.id)"></span>
</a>
</td>
</tr>
</table>
<table>
<tr ng-repeat="r in rvm"></tr>
</table>
</div>
</div>
 
JS
var ReceiptsApp = angular.module('ReceiptsApp', []);
ReceiptsApp.controller('ReceiptsController', function ($scope) {
$scope.sample = [{
id: '1',
name: 'Bhanu',
Address: 'Moosapet',
Mobile: '9246100100'
}, {
id: '2',
name: 'Madhu',
Address: 'Uppal',
Mobile: '9000330653'
}, {
id: '3',
name: 'Geetha',
Address: 'Sanath Nagar',
Mobile: '9912340519'
}];
$scope.rvm = [{}];
$scope.addRow = function (index, c) {
if ($scope.rvm.length == (index + 1)) {
$scope.rvm.push({
});
}
}
});

Answers (3)