Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to catch blur or focus event in angularJS directive

I have directive with input

<input ng-model="inputModel" ng-disabled="ngDisabled || isLoading" value="{{value}}" type="{{type}}" placeholder="{{placeholder | translate}}">

I use this directive like this:

<input-ext type="'text'" name="email" ng-model="registerCtrl.email" ng-blur="registerCtrl.test()" required></input-ext>

I want to after blur inside my directive to executed blur in input-ext ... , for this example code in controller, how to make this ?

like image 643
Artur Kasperek Avatar asked Dec 02 '22 16:12

Artur Kasperek


1 Answers

On your link function you bind them

   link: function (scope, element, attrs) {
        element.bind('blur', function (e) {
             //do something
        });
   }
like image 198
Ahmet Zeytindalı Avatar answered Dec 05 '22 06:12

Ahmet Zeytindalı