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

Function maxlengthDirective

lib/test/angular/1.5.0/angular.js:30164–30182  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30162 * </example>
30163 */
30164var maxlengthDirective = function() {
30165 return {
30166 restrict: 'A',
30167 require: '?ngModel',
30168 link: function(scope, elm, attr, ctrl) {
30169 if (!ctrl) return;
30170
30171 var maxlength = -1;
30172 attr.$observe('maxlength', function(value) {
30173 var intVal = toInt(value);
30174 maxlength = isNaN(intVal) ? -1 : intVal;
30175 ctrl.$validate();
30176 });
30177 ctrl.$validators.maxlength = function(modelValue, viewValue) {
30178 return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);
30179 };
30180 }
30181 };
30182};
30183
30184/**
30185 * @ngdoc directive

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected