angularjs - Angular Nested form fields using directive -
I am trying to create a form dynamically using the server response. There may be fields in the form that are nested, grouped and so on. I have tried to make a command as 'field-field' for my field type and issued ng-included instructions for all nested fields.
When I use this UL-Lee, the output looks correct, but when I start using the field and textfield, the output is not render completely for the text field is.
// Code has come here angular. Module ('nestedform', []). Controller ('formController', function ($ scope) {}) Instructions ('formField', Function ($ Collection) {Return {Replace: True, Required: 'ngModel', Scope: {data: 'data', ngModel: '='}, Restrict: 'E', Link : Function ($ scope, $ element, $ attrs) {var type = $ scope.data.type; var html = ""; switch (type) {case 'textbox': Html = '& lt; input id = \' '+ $ Scope.data.name +' \ 'type = "text" ng-model = "ngmodel" class = "form-control" & gt;' break; case 'field': html = '& lt; field set & Gt; & lt; Legend & gt; '+ $ scope.data.name +' & lt; / legend & gt; & lt; / fieldset & gt;; break; default: break;} var $ e = $ compile (Html) ($ radius); $ element.replaceWith ($ e);}}});
Appreciate your help.
First of all, your question is too long, many people just want to read the questions, understand, and Answer: Do they know about it. If the question is too long, then we do not read fast, the understanding is not correct, and the answer does not come from a complete understanding of your question.
I do not completely read your question, but it seems that you are replacing the whole element.
Check it out.
var $ e = $ collection (html) ($ radius); $ Element.append ($ E); // instead of changing it
Comments
Post a Comment