Skip to content Skip to sidebar Skip to footer

Angularjs : Replicate Div On Click Of Button

I want to replicate the text fields(div) present in image every time the user click on '+' button.

Solution 1:

If I understood your question properly , pls refer the below code .

Template

<divng-app="myapp"ng-controller="myCtrl"><divng-repeat="item in items"><inputtype="text"placeholder="name"><inputtype="text"placeholder="email"><buttonng-click="add()">+</button><p>Some text some text some text</p></div></div>

controller

var app = angular.module('myapp',[]);

app.controller('myCtrl',["$scope",function($scope){

    $scope.items = [{}];

    $scope.add = function(){
       $scope.items.push({});
    }

}]);

refer: https://jsfiddle.net/ftzebggn/

Post a Comment for "Angularjs : Replicate Div On Click Of Button"