I have a situation where a button is provided for the user to click. After clicking the button, a new <div>
(which is actually a template with isolated scope) is created, and this <div>
is appended to the existing element, like so:
<button ng-click="openNewDiv()"></button>
<div>Div content for DIV 1</div>
<div>Div content for DIV 2</div>
<div>Div content for DIV 3</div>
<div>Div content for DIV 4</div>
Each <div>
shares the same template and logic, with isolated scope, when user clicks the button, a fifth <div>
is appended next to DIV4
, which also shares the same logic as the above 4 <div>
's, how can I achieve this in AngularJS? I am reading this article to find the solution, am I on the right direction?
http://odetocode.com/blogs/scott/archive/2014/05/07/using-compile-in-angular.aspx