AngularJS林记过滤stoppropagation [英] AngularJS Linky filter stoppropagation

查看:122
本文介绍了AngularJS林记过滤stoppropagation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个跨度标记,看起来像这样:

I have a span tag that looks like this:

<span ng-bind-html="item.Name | linky" ng-click="open(item)"></span>

这是NG重复之内。

我有一个问题,但如果 item.Name 包含电子邮件或链接林记过滤器改变了HTML,并插入一个锚标记。现在,当我点击链接的NG-点击火灾和锚打开,但我只想锚打开和被调用prevent NG单击...这可能吗?

I have a problem though, if item.Name contains an email or link the linky filter changes the html and inserts an anchor tag. Now when I click the link the ng-click fires AND the anchor opens, but I only want the anchor to open and prevent ng-click from being called ...is this possible?

推荐答案

如何像这样为HTML代码:

How about something like this for your html:

<span ng-bind-html="item.Name | linky" ng-click="open(item, $event)"></span>

这为你的函数调用:

And this for your function call:

$scope.open = function(item, event){
    if(event.srcElement.tagName !== 'A'){
        alert('do something here with ' + item.Name);
    }        
}

有可能是一个更好的办法,但我相信这会奏效。虽然它的文档中我看到 $事件 这组文章。

There may be a better way but I believe this will work. Although it's in the documentation I saw $event in this group article.

这篇关于AngularJS林记过滤stoppropagation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆