Answer the question
In order to leave comments, you need to log in
Angular JS: How to describe a callback directive to be used on a single element?
The essence of the question is how to make a directive, like ng-click or ng-change, but without using an isolated scope.
Let's say there are 2 directives: onEvent1 onEvent2, these 2 events are associated with the element and callbacks are passed to them: ....
The easiest way to call these callbacks is to describe the directives using scope { handler: '&onEvent1' }:
...
.directive('onEvent1', function () {
return {
restrict: 'A',
scope: { handler: '&onEvent1' },
link: function (scope, e, a) {
e.bind('нужное событие', function () { scope.handler(); });
}
};
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question