angularjs - Add an element in angular js -
i looking way insert items inside elements in angular js.
ill try show how is.
<item1> </item1>
insert item this
<item1> <item2> </item2> </item1>
it should insert data require (it means must execute template of item2 when initialize).
i want insert items dynamically, while press button new element inserted item1. new 1 of different type type2 , should inherit propertys , attributes of it's kind (item3, item3.. , on).
you can achieve using ng-include.
<item data-ng-include="'partials/your-template.html'"></item>
and attach own controller if needed.
<item ng-controller="yourctrl" data-ng-include="'partials/your-template.html'"></item>
you can create custom directive floribon advice, use ng-repeat, ng-bind-html...
update comment
use ng-show in case
<item ng-show="isclicked">{{data}}</item> <button ng-click="isclicked = true">insert</button>
that's basics of angular use, must read bible before become priest.
Comments
Post a Comment