考虑以下代码(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 中)中的按钮和锚点与模板内部文本“这是我的指令内容”结合在一起。
如果我将版本更改为1.2.1,my-directive 内容将替换模板内部文本。
有没有办法让 angular 1.2.1(及更高版本)执行较旧的行为?