R
R
Rrooom2014-08-14 10:01:48
JavaScript
Rrooom, 2014-08-14 10:01:48

Is it possible to hang an event on all inputs in Angular?

There is a large form, depending on what is selected, the content of the page changes.

How to properly hang an on-blur handler on all page inputs to make an ajax request?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Sergey, 2014-08-14
Protko @Fesor

angular.module('app')
.directive('ngBlurDelegate', function ($parse) {
    return {
        restrict: 'A',
        link: function (scope, el, attr) {
             var callback = $parse(attr.ngBlurDelegate);
             el.on('blur', function () {
                  //.. тут что-то делать
                  callback(scope);
             });
        }
    }
});

<form ng-blur-delegate="callback()">
...
</form>

Something along those lines.

T
TekVanDo, 2014-08-14
@TekVanDo

What is the problem? https://docs.angularjs.org/api/ng/directive/ngBlur

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question