Adeel Khan Adeel Khan - 1 year ago 62
Javascript Question

how to get array values from $scope variable angularjs

how to add Table row in button click event angularjs please check below image

<div class="col-md-2">
<a href="" data-toggle="tooltip" title="Add Address" ng-click="addRow()"><i class="fa fa-plus fa-2x cust_primary" aria-hidden="true">

enter image description here

Answer Source

In your controller, create a counter and an array.

$scope.i = 0;
$scope.array = [];

Everytime your user clicks on the button, add one to the counter and create the array.

$scope.addRow = function() {
    $scope.array = [];
    for(var i = 0; i < $scope.i; i++) {

In your html, simply repeat the lines based on that counter.

<tr ng-repeat="lines in array">
    // Your tds
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download