PipeMan
PipeMan

Reputation: 141

JQuery and Angular: Add two functions in ng-keydown

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()');

Upvotes: 1

Views: 310

Answers (1)

fracz
fracz

Reputation: 21278

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.

Upvotes: 1

Related Questions