dude
dude

Reputation: 6086

How to pass the input element as a parameter in ng-blur?

This is my input:

<input type="number" value="{{ bom.Id._Value }}" name="id" data-ng-model="bom.Id._Value" data-ng-blur="myClass.myFunc();" required>

If I pass this or angular.element(this) in the ng-blur I don't get the input element in the function. What I want is to receive the current input element in myFunc() as a parameter. What is the standard way for it?

Upvotes: 9

Views: 11818

Answers (1)

Aravinder
Aravinder

Reputation: 503

<input type="number" value="{{ bom.Id._Value }}" name="id" data-ng-model="bom.Id._Value" data-ng-blur="myClass.myFunc($event);" required>

In Controller:

myClass.myFunc = function(e){
  console.log(e.target);
};

Upvotes: 11

Related Questions