【发布时间】:2012-09-19 16:44:38
【问题描述】:
如何防止指令与 transclude 创建新的范围?
这个jsfiddle我无法绑定任何东西,因为新的范围用红色边框表示。
HTML:
<div ng-app="components">
<input ng-model="var">
<block>
123
<input ng-model="var">
</block>
</div>
JavaScript:
angular.module('components', []).directive('block',function(){
return{
scope:false,
replace:true,
restrict:"E",
transclude:true,
template:'<div class="block" ng-transclude></div>',
link:function(scope, el, attrs, ctrl){
}
}
});
CSS:
.ng-scope{
border:1px solid red;
margin:10px;
}
【问题讨论】:
标签: javascript html binding angularjs