里面的标记文字Angular.js输出标记之外 [英] Text inside tag outside of output tag in Angular.js

查看:103
本文介绍了里面的标记文字Angular.js输出标记之外的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在HTML链接标签:

I have a link tag in HTML:

<link url="http://google.com">google</link>

和code,它转换成&LT; A&GT; 标签:

and code that transform it to <a> tag:

app.directive('link', function() {
    return {
        restrict: 'E',
        transclude: true,
        replace: true,
        scope: {
            url: '@'
        },
        template: '<a href="{{url}}" ng-transclude></a>'
    }
});

但是使用这个文本是谷歌之外,URL不会被删除(复制如果从链接到一个标签)。如果我使用一个属性,它工作正常&LT; D​​IV链接URL =htt​​p://google.com&GT;谷歌&LT; / DIV&GT; 什么是错的?

下面是结果的jsfiddle

推荐答案

我想我知道这样做的原因,在链接如果HTML标记(即从头部到包括样式表),它是一个自我结束标记,并且接缝在执行前角解析器如何解析它。

I think I know the reason for this, the link if html tag (that from head to include stylesheet) that is single self closing tag, and it seams that how parser parse it before Angular is executed.

这篇关于里面的标记文字Angular.js输出标记之外的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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