我有一个截取链接点击的指令:
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
不会触发上面的指令代码。
https://stackoverflow.com/questions/42150592
复制相似问题