I would like to pass my SPA a JSON array and render controls and directives based on what is in the array.
I have all the controls rendering based on the answer found here; plunker link
However, I also have custom directives that I'd like to render but I don't want to specify each of them in the HTML. Instead I'd like to just do something like;
<div ng-if="field.type=='directive'" class="form-group {{field.css}}">
<{{field.directive}}></{{field.directive}}>
</div>
and then in the JSON object specify which directive to render;
app.directive("testDirective", function(){
return {
restrict: 'E',
scope: {},
template: '<h2>This is a custom directive to show that we can render these also.</h2>',
replace: true
};
})
And add that directive to the list of controls to render;
fields :
[
{type: "directive", directive:"test-directive", name: "td1", data: ""},
The code I have created simply outputs;
<test-directive>
as text and not as the control itself.
Any thoughts?