Roland,
Your are not seeing the value in the first input bound to `user.name`
because of validation failure of ng-minlength, if you have the value with
length grater then or equal to 5 it would show it. This is the validation
criteria used by ng-minlenght `ctrl.$isEmpty(value) || value.length >=
minlength` if it fails (in your case it does) the value is set to
`undefined` as per the below validation code from
https://code.angularjs.org/1.2.16/angular.js
// min length validator
> if (attr.ngMinlength) {
> var minlength = int(attr.ngMinlength);
> var minLengthValidator = function(value) {
> return validate(ctrl, 'minlength', ctrl.$isEmpty(value) || value.length
> >= minlength, value);
> };
>
> ctrl.$parsers.push(minLengthValidator);
> ctrl.$formatters.push(minLengthValidator);
> }
>
> // max length validator
> if (attr.ngMaxlength) {
> var maxlength = int(attr.ngMaxlength);
> var maxLengthValidator = function(value) {
> return validate(ctrl, 'maxlength', ctrl.$isEmpty(value) || value.length
> <= maxlength, value);
> };
>
> ctrl.$parsers.push(maxLengthValidator);
> ctrl.$formatters.push(maxLengthValidator);
> }
>
>
On Thursday, 24 April 2014 20:26:04 UTC+5:30, Roland Zwaga wrote:
>
> Hi there,
>
> I'm busy creating a directive that adds validation directives to its
> contents dynamically,
> so, this directive has a 'priority' of 1000 and 'terminal' set to true.
> That way I can halt compilation,
> add my stuff and invoke $compile() manually, but I have run into some
> behavior that puzzles me.
>
> In short, when I add a ng-minlength directive the ngModel seems to get
> screwed up.
>
> I have created a very simple example in this plunkr:
>
> http://plnkr.co/edit/xtmhZaIQNlp8zsZQYzvQ?p=info
>
> As you'll see, the textinput that has an ng-minlength directive won't show
> the model data.
> However, the other directive, ng-maxlength, works without problems. (As
> have other directives
> I've tried).
>
> I am scratching my head over this and I really hope someone can explain
> what I'm doing
> wrong here...
>
> thanks a lot in advance,
>
> Roland Zwaga
>
--
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 http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.