Text inside tag outside of output tag in Angular.js

你离开我真会死。 提交于 2019-12-13 21:02:24

问题


I have a link tag in HTML:

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

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>'
    }
});

But using this text Google is outside and URL is not removed (it copy if from link to a tag). If I use an attribute it works fine <div link url="http://google.com">google</div> What's wrong?

Here is
jsFiddle.


回答1:


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.



来源:https://stackoverflow.com/questions/18268090/text-inside-tag-outside-of-output-tag-in-angular-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!