olivierGrech olivierGrech - 2 years ago 87
HTML Question

AngularJS - Repeating a div and a button

I want to use ng-repeat to repeat a div. This div also has a button within it.

Currently, I'm doing it by creating the div and the button in the javascript part and pushing the final result in an array :

var newDiv = document.createElement('div');
var newButton = document.createElement('button');

I have 2 questions :

1) What should be the html syntax ? Is the following correct ?

<div id='main_chart_div' ng-repeat="x in arrayDiv" value={{x}}></div>

2) Is there a way to do that without manipulating the DOM ?

Answer Source

You can have the button in your template:

<div id='main_chart_div' ng-repeat="x in arrayDiv" value={{x}}>

By the way, you shouldn't repeat an element with a static id.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download