我有这个指令拦截链接点击:
var app = angular.module('mobApp.services');
app.directive('a', function() {
return {
restrict: 'E', // only Elements (<a>),
link: function(scope, elm, attr) {
elm.on('click', function($event) {
$event.preventDefault()
var href = attr.href;
if(!!href && href !== '#') {
window.open(href, '_system', 'location=yes');
}
return false
})
}
}
})
我有这个元素
<p ng-bind-html="post.details | linky:'_blank'" class="ng-binding">
<a target="_blank" href="https://davidwalsh.name/speech-recognition" class="">
https://davidwalsh.name/speech-recognition
</a>
</p>
点击a
不会触发上述指令代码。