永远不会调用Angularjs链接函数。
源代码包含在webpack包中。
角度版本是v1.6.6
import angular from 'angular';
const module = angular.module('app.directives.ax', []);
console.log('included directive');
module.directive('ax', function() {
return {
restrict: 'AEC',
link: function(scope, elem, attrs) {
console.log('from directive');
console.log('from directive xxx');
elem.css('cursor', 'pointer');
if (attrs.ngClick || attrs.href === '' || attrs.href === '#') {
elem.on('click', function(e){
e.preventDefault();
});
}
}
};
});
export default module.name;
在html模板中我有
<a class="default-link ax" ng-click="vm.delete(announcement.id)"><i class="fa fa-trash-o"></i></a>