私は AngularJS と jQuery を使用iElementしていelementます。以下btn1もbtn2機能し、elementjQueryiElementによってラップされます。
var app = angular.module('myApp', []);
app.directive('btn1', function () {
return function (scope, element) {
element.click(function () {
$(this).css('background', '#666');
});
};
});
app.directive('btn2', function () {
return function (scope, iElement) {
iElement.click(function () {
$(this).css('background', '#666');
});
};
});