1
I’m building an application that needs to render a dynamic form.
The form data comes from a json
, and in it, I have the configuration of the fields.
Following example:
{
"Fields": [
{
"title": "Assunto",
"type": "text"
},
{
"title": "Email da tia",
"type": "email",
}]
}
Is there any way to create directives dynamically, using attribute or class, setting high Priority?
For example:
<section ng-repeat="field in Fields">
<field-builder data-type="field.type"></field-builder>
</section>
And in this directive, field Builder, it generate directives by returning for example(with smaller Priority):
<span class="text"></span>
<span class="email"></span>
Existing of course, a way to compile each after ng-repeat.
Some way to do this?
I think it’s best to generate an HTML and append it to a div with the attribute
ng-bind-unsafe
, if I’m not mistaken. But I’ve never done it. I just think it works.– Vinícius Gobbo A. de Oliveira
No use, need to use other attributes, mount selects, use masks...
– Marcelo Aymone
That’s why you need the attribute
ng-bind-unsafe
. If pro mount you mean "use", I believe it works. But as I said, just testing.– Vinícius Gobbo A. de Oliveira