What I'm trying to do:
Is there any way to use an array of elements to populate a div with children in AngularJS?
I want to be able to have an array of custom elements, and as I update the array, it updates the view. The directives for the custom elements need to $scope.$digest() the elements each time I make an update.
Pseudo Code:
html
<div id="parent" ng-controller="parentCtrl" ng-bind-html="arrOfElems"></div>
Javascript
app.controller('levelCtrl', ['$scope', '$compile', '$element', function(scp, cmpl, elem) {
scp.arrOfElems = ['<ell></ell>', '<r-ell></r-ell>', '<sqr></sqr>'];
}]);
app.directive('ell', function() {
return {
restrict: 'E',
template: <div class="block"></div>
};
});
app.directive('rEll', function() {
return {
restrict: 'E',
template: <div class="block"></div>
};
});
app.directive('sqr', function() {
return {
restrict: 'E',
template: '<div class="block"></div>'
};
});
Ideally, the resulting html would be:
<div id="parent" ng-controller="parentCtrl" ng-bind-html="arrOfElems">
<ell>
<div class="block"></div>
</ell>
<r-ell>
<div class="block"></div>
</r-ell>
<sqr>
<div class="block"></div>
</sqr>
</div>