Hi, i new in group, but with problems

I created a directive to mount forms the app, do ngrepeat to get the 
information from the fields and set the template.

The problem is when I try to record the ngmodel the resource, I do not know 
how to do.


t

*emplate directive:*
<field-create ng-repeat="field in grupo.fields" field="field" ng-model=
"item.grupos"></field-create>


*Directive*:

    .directive('fieldCreate', function($compile, $timeout) {
    
        var inputtpl    = 
'<md-input-container><label>{{field.title}}</label><input 
ng-model="item.grupo.fields.model"></md-input-container>';
        var textareatpl = 
'<md-input-container><label>{{field.title}}</label><textarea 
ng-model="item.grupo.fields.model" columns="1" 
md-maxlength="300"></textarea></md-input-container>';
        var checkboxtpl = '<md-checkbox 
ng-model="item.grupo.fields.model">{{field.title}}</md-checkbox>';
    
        var getTemplate = function(fieldType) {
            var template = '';
    
            switch(fieldType) {
                case 'input':
                    template = inputtpl;
                    break;
                case 'textarea':
                    template = textareatpl;
                    break;
                case 'checkbox':
                    template = checkboxtpl;
                    break;
            }
            return template;
        }
    
        var linker = function(scope, element, attrs) {
            element.html(getTemplate(scope.field.type));
            $timeout(function(){
                $compile(element.contents())(scope);
            });
        }
    
        return {
            restrict: "E",
            replace: true,
            require: 'ngModel',
            link: linker,
            scope: {
                field: '=',
                model: '=ngModel'
            }
        }
    
    });


-- 
You received this message because you are subscribed to the Google Groups 
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to angular+unsubscr...@googlegroups.com.
To post to this group, send email to angular@googlegroups.com.
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to