I am trying to dynamically generate a form using an array containing a bunch of directive names
$scope.components = ["textbox", "textbox", "radio", "checkbox", "label"];
I want to create tags with these names using angular. for instance
<textbox></textbox>
<textbox></textbox>
<radio></radio>
<checkbox></checkbox>
<label></label>
<--THE FOLLOWING DOESN'T WORK BUT WOULD BE COOL IF IT DID-->
<{{component}} ng-repeat="component in components track by $index"></{{component}}>
Now, as an alternative, I am doing the following
<div ng-include="component + '.html'" ng-repeat="component in components track by $index"></div>
Which basically does what the directive will do with the templateUrl parameter. Should I
- create a directive that generates tags
- keep using ng-include as i
- use another method
source
share