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

Function maxlengthDirective

lib/test/angular/1.7.0/angular.js:34832–34850  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

34830 * </example>
34831 */
34832var maxlengthDirective = function() {
34833 return {
34834 restrict: 'A',
34835 require: '?ngModel',
34836 link: function(scope, elm, attr, ctrl) {
34837 if (!ctrl) return;
34838
34839 var maxlength = -1;
34840 attr.$observe('maxlength', function(value) {
34841 var intVal = toInt(value);
34842 maxlength = isNumberNaN(intVal) ? -1 : intVal;
34843 ctrl.$validate();
34844 });
34845 ctrl.$validators.maxlength = function(modelValue, viewValue) {
34846 return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);
34847 };
34848 }
34849 };
34850};
34851
34852/**
34853 * @ngdoc directive

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected