How to append div element onclick in angularjs

Orange Mint

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>
Rowen Pimentel

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.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to append div element onclick in angularjs

From Dev

how to append div into one div using angularjs

From Dev

Append an element with onclick parameter

From Dev

How to append element in post function of compile - AngularJS

From Dev

How add element to div in angularjs?

From Dev

how to append a div directly into en element in BackboneJs

From Dev

Javascript how to append an element to div with specific class

From Dev

AngularJs Render div onclick

From Dev

AngularJs Render div onclick

From Dev

how to get clone element of queryselectorall and append to another div

From Dev

How do i append slide to particular div element?

From Dev

How to create Html to pdf on particular div onclick button in angularjs?

From Dev

Append element to each div in order

From Dev

How to append to a div that was just append

From Dev

how do I disable all onClick on a child element of a div

From Dev

How to onclick outside an input element which is inside a div?

From Dev

How to append element to body?

From Dev

How to append an element to a textblock?

From Dev

How to append an element to HList

From Dev

How to append data to an element

From Dev

how to append onClick event in jquery

From Dev

Hide DIV element with onclick command

From Dev

Onclick an element, sliding toggle of div

From Dev

how to append to div id

From Dev

Jquery - How to append div with numeric id generate by PHP to div with element link with same numeric value

From Dev

How to append div for each div

From Dev

How to append div for each div

From Dev

How to append a div to another div

From Dev

How to delete element onclick