加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS transclude不起作用

发布时间:2020-12-17 17:18:39 所属栏目:安全 来源:网络整理
导读:这个例子适用于AngularJS 1.1.5(它会将它附加到div中),但是1.2.5不能(它会留下没有附加的html内容). https://egghead.io/lessons/angularjs-transclusion-basics app.directive("panel",function() { return { restrict: "E",transclude: true,template: 'di
这个例子适用于AngularJS 1.1.5(它会将它附加到div中),但是1.2.5不能(它会留下没有附加的html内容).

https://egghead.io/lessons/angularjs-transclusion-basics

app.directive("panel",function() {
    return {
        restrict: "E",transclude: true,template: '<div class="panel" ng-transclude>This is a panel component</div>'
    }
})

AngularJS 1.1.5:http://plnkr.co/edit/BLe56D9YZxSIAiJ31wW0(“这是……”按预期显示)AngularJS 1.2.5:http://plnkr.co/edit/h6dUrXXXBOQUtzsJqT4S(“这是……”没有出现)

在1.1.5“transclude:true”按预期工作(文本附加到面板),但在> 1.2.0没有.

有帮助吗?

解决方法

将指令中的模板更改为:

template: '<div class="panel" >This is a panel component</div><div ng-transclude></div>'

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读