You should use ng-repeat to render an array of divs.
Here is some sample controller code:
$scope.divs = [{
name: 'I\'m just a default DIV'
}];
$scope.add_div = function() {
// this is simply pushing some new Data to an array
// that will be rendered in a ng-repeat.
// You can instead use angulars $http helper
// to load Data to your scope
$scope.divs.push({
name: 'I\'m another DIV'
})
}
And this is the html code to render the array of divs:
<div ng-repeat="div in divs">{{div.name}}</div>
See an example Plunker here
Update:
If you want to render html snippets returned from your server in a ng-repeat you must take some extra action:
- Include angular sanitize in your app.
Inside the repeat wrap your output in another div that is rendered as unsafe html (In my plunker achieved via a filter):
<div ng-repeat="div in divs">
<div ng-bind-html="div.name | unsafe"></div>
</div>
This way you can render your old html snippets, although I still think this is no good idea.
See the updated Plunker here