We have the following scenario:

there is an container which can have x input elements (x >= 0)
Each input element use normal ng-binds

In the container there is an function which adds an $parsers 
and $validators to each included ngModelController.

the code is the following:

<form-element>
   <fs-input-a ng-required="true" ng-model="model.streetname" 
name="streetname"></fs-input-a>
   <fs-input-b ng-required="true" ng-maxlength="5" ng-pattern="/\d$/" 
ng-model="model.streetnr" name="streetnr"></fs-input-b>
</form-element>

In the link method of the "form-element" directive we call something like 
this:

var controls   = element[0].querySelectorAll('[ng-model]'),
    i, ngModel;

// Get all ngModel controllers
if (controls.length) {
    for (i = 0; i < controls.length; i++) {
        ngModel = angular.element(controls[i]).controller('ngModel');
        ngModel.$parsers.push(function(value) {
          ...
        }.bind(ngModel));
        ngModel.$validators.removeHidden = function() {
            // on validation remove the hideError flag
            this.$hideError = undefined;
            return true;
        }.bind(ngModel);
    }
}



This worked fine under AngularJS 1.4.x

In AngularJS 1.5.x it works only if the template in the input directives it 
directly defined via template: '...'
If we use templateUrl: '...' we have now the problem that ngModel will be 
undefined.
In the controls[i] I get the right element and there is a ng-model 
attribute but it seems that AngularJS 1.5 haven't compiled the element.

Is there a better way to manipulate the ngModels of the child elements?



-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.

Reply via email to