1

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>
1
  • Push to items on ng-click. Commented Sep 16, 2013 at 4:41

1 Answer 1

3

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.

Sign up to request clarification or add additional context in comments.

1 Comment

you mean: $scope.items.push(new_object); ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.