Angularjs   发布时间:2022-04-20  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了angularjs – Transclusion(true) – 组合值大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
虑以下代码( 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>
<@L_607_2@ 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>@H_419_14@ 
 

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

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

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

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

解决方法

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

大佬总结

以上是大佬教程为你收集整理的angularjs – Transclusion(true) – 组合值全部内容,希望文章能够帮你解决angularjs – Transclusion(true) – 组合值所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。