angularjs - Angular directive link function with 4 arguments? -


in angular developer guide find example:

var integer_regexp = /^\-?\d+$/; app.directive('integer', function() {   return {     require: 'ngmodel',     link: function(scope, elm, attrs, ctrl) {       ctrl.$parsers.unshift(function(viewvalue) {         if (integer_regexp.test(viewvalue)) {           // valid           ctrl.$setvalidity('integer', true);           return viewvalue;         } else {           // invalid, return undefined (no model update)           ctrl.$setvalidity('integer', false);           return undefined;         }       });     }   }; }); 

q) fourth argument in link function, , bind to? thought link function take 3 arguments.

it's controller or array of controllers, specified in required property of directive definition object. in particular case it's controller of ngmodel directive on same element

more info here


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -