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

Function maxlengthDirective

test/angular/1.5/angular.js:32355–32373  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

32353 * </example>
32354 */
32355var maxlengthDirective = function() {
32356 return {
32357 restrict: 'A',
32358 require: '?ngModel',
32359 link: function(scope, elm, attr, ctrl) {
32360 if (!ctrl) return;
32361
32362 var maxlength = -1;
32363 attr.$observe('maxlength', function(value) {
32364 var intVal = toInt(value);
32365 maxlength = isNumberNaN(intVal) ? -1 : intVal;
32366 ctrl.$validate();
32367 });
32368 ctrl.$validators.maxlength = function(modelValue, viewValue) {
32369 return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);
32370 };
32371 }
32372 };
32373};
32374
32375/**
32376 * @ngdoc directive

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected