MCPcopy Index your code
hub / github.com/angular-ui/ui-router / maxlengthDirective

Function maxlengthDirective

test/angular/1.4/angular.js:29586–29604  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29584 * </example>
29585 */
29586var maxlengthDirective = function() {
29587 return {
29588 restrict: 'A',
29589 require: '?ngModel',
29590 link: function(scope, elm, attr, ctrl) {
29591 if (!ctrl) return;
29592
29593 var maxlength = -1;
29594 attr.$observe('maxlength', function(value) {
29595 var intVal = toInt(value);
29596 maxlength = isNaN(intVal) ? -1 : intVal;
29597 ctrl.$validate();
29598 });
29599 ctrl.$validators.maxlength = function(modelValue, viewValue) {
29600 return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);
29601 };
29602 }
29603 };
29604};
29605
29606/**
29607 * @ngdoc directive

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected