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

angularjs – Transclusion(true) – 组合值

发布时间:2020-12-17 16:58:26 所属栏目:安全 来源:网络整理
导读:请考虑以下代码( http://jsbin.com/IfejIWES/1/): HTML: !DOCTYPE htmlhtml ng-app="myApp"headscript src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.3/angular.min.js"/scriptmeta charset=utf-8 /titleJS Bin/title/headbody div ng-contr
请考虑以下代码( http://jsbin.com/IfejIWES/1/):

HTML:

<!DOCTYPE html>
<html ng-app="myApp">
<head>
<script src="http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.1.3/angular.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div ng-controller="MyCtrl">

    <div my-directive>
        <button>some button</button>
        <a href="#">and a link</a>
    </div>
</div>
</body>
</html>

JS:

var myApp = angular.module('myApp',[]);

function MyCtrl($scope) {
    //$scope.log=[];   
}

myApp.directive('myDirective',function(){
    return{
        transclude: true,template: '<div class="something" ng-transclude> This is my directive content</div>'
    };
});

使用AngularJS的1.1.3版,输出将my-directive(在HTML中)的按钮和锚点与模板内部文本“This is my directive content”结合起来.

如果我将版本更改为1.2.1,则my-directive内容将替换模板内部文本.

有没有办法让角度1.2.1(及更高版本)做旧的行为?

解决方法

不,这是一次非常故意的改变.见 this commit.

(编辑:李大同)

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

    推荐文章
      热点阅读