1

Adding two functions in ng-keydown through the use of jQuery attr

How can I do this the right way.

$('#id').attr('ng-keydown', 'maxinput(), numericOnly()');
PipeMan
  • 141
  • 1
  • 14

1 Answers1

1

I agree with @pixelbits that you should create a custom validator for the purpose you are trying to achieve. In fact, you can even use ng-maxlength and set input type to number to have the validation you require OOTB.

But if you really want to call multiple functions in an ng-* handler (it can be click, keydown etc), you should separate calls with semicolon ; instead of comma.

You might also want to read how to think in Angular way with jQuery background.

Community
  • 1
  • 1
fracz
  • 20,536
  • 18
  • 103
  • 149