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

Function maxlengthDirective

lib/test/angular/1.6.7/angular.js:33920–33938  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

33918 * </example>
33919 */
33920var maxlengthDirective = function() {
33921 return {
33922 restrict: 'A',
33923 require: '?ngModel',
33924 link: function(scope, elm, attr, ctrl) {
33925 if (!ctrl) return;
33926
33927 var maxlength = -1;
33928 attr.$observe('maxlength', function(value) {
33929 var intVal = toInt(value);
33930 maxlength = isNumberNaN(intVal) ? -1 : intVal;
33931 ctrl.$validate();
33932 });
33933 ctrl.$validators.maxlength = function(modelValue, viewValue) {
33934 return (maxlength < 0) || ctrl.$isEmpty(viewValue) || (viewValue.length <= maxlength);
33935 };
33936 }
33937 };
33938};
33939
33940/**
33941 * @ngdoc directive

Callers

nothing calls this directly

Calls 1

toIntFunction · 0.70

Tested by

no test coverage detected