Reputation: 939
I am looking for a way to insert items inside elements in angular js.
Ill try to show how it is.
<item1> </item1>
insert an item like this
<item1>
<item2> </item2>
</item1>
It also should insert all the data you require (it means it must execute the template of item2 when initialize).
I want to insert items dynamically, while press a button a new element is inserted into item1. The new one will be of a different type type2 and should inherit all the propertys and attributes of it's kind (item3, item3.. and so on).
Upvotes: 0
Views: 72
Reputation: 1015
You can achieve this using ng-include.
<item data-ng-include="'partials/your-template.html'"></item>
And attach to his own controller if needed.
<item ng-controller="YourCtrl" data-ng-include="'partials/your-template.html'"></item>
You can also create a custom directive like floribon advice, use ng-repeat, ng-bind-html...
Update from your comment
Use ng-show in this case
<item ng-show="isClicked">{{data}}</item>
<button ng-click="isClicked = true">insert</button>
That's the basics of angular use, you must read the bible before become a priest.
Upvotes: 2