나는이 doc을 통해 갈 것이고, 내가 가지고있는 혼란은 link.apply (this, attrs)에서 'this'이다. 누군가 도울 수 있습니까?각도 데코레이터에서 'this'는 무엇입니까?
$provide.decorator('fooDirective', function($delegate) {
var directive = $delegate[0];
directive.scope.fn = "&";
var link = directive.link;
directive.compile = function() {
return function(scope, element, attrs) {
link.apply(this, arguments);
element.bind('click', function() {
scope.$apply(function() {
scope.fn();
});
});
};
};
return $delegate;
});
});
콘솔 디버거를 사용하여 디버깅하려고하면 링크 기능이 실행되는 동안 'this'가 정의되지 않습니다.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply – Sai