I would like to have a self-appending input box when I click on an "add more" button.
What I currently have is the following, in which I hope that when I click on the link, the input will append itself with each click.
<div ng-repeat="item in items" slide-show="showInput">
<input name="item.id">
</div>
<div>
<a href ng-click="showInput=true">add more</a>
<div>
Just add a new item in items array.
function SampleCtrl ($scope) {
$scope.items = [obj1,obj2,obj3];
$scope.showItem = false;
$scope.addItem = function () {
//it's up to you how you want to structure the new_object.
var new_object;
$scope.showInput = true;
$scope.items.push(new_object);
}
}
In your ng-click
call the addItem
function instead.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments