MCPcopy Create free account
hub / github.com/angular-ui/ui-router / maxlengthDirective

Function maxlengthDirective

test/angular/1.6/angular.js:34609–34627  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34607 * </example>
34608 */
34609var maxlengthDirective = function() {
34610 return {
34611 restrict: 'A',
34612 require: '?ngModel',
34613 link: function(scope, elm, attr, ctrl) {
34614 if (!ctrl) return;
34615
34616 var maxlength = -1;
34617 attr.$observe('maxlength', function(value) {
34618 var intVal = toInt(value);
34619 maxlength = isNumberNaN(intVal) ? -1 : intVal;
34620 ctrl.$validate();
34621 });
34622 ctrl.$validators.maxlength = function(modelValue, viewValue) {
34623 return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);
34624 };
34625 }
34626 };
34627};
34628
34629/**
34630 * @ngdoc directive

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected