MCPcopy Create free account
hub / github.com/EricSimons/ionic-course / maxlengthDirective

Function maxlengthDirective

code/songhop/www/lib/angular/angular.js:21289–21307  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

21287
21288
21289var maxlengthDirective = function() {
21290 return {
21291 restrict: 'A',
21292 require: '?ngModel',
21293 link: function(scope, elm, attr, ctrl) {
21294 if (!ctrl) return;
21295
21296 var maxlength = -1;
21297 attr.$observe('maxlength', function(value) {
21298 var intVal = int(value);
21299 maxlength = isNaN(intVal) ? -1 : intVal;
21300 ctrl.$validate();
21301 });
21302 ctrl.$validators.maxlength = function(modelValue, viewValue) {
21303 return (maxlength < 0) || ctrl.$isEmpty(modelValue) || (viewValue.length <= maxlength);
21304 };
21305 }
21306 };
21307};
21308
21309var minlengthDirective = function() {
21310 return {

Callers

nothing calls this directly

Calls 1

intFunction · 0.70

Tested by

no test coverage detected