当创建与一个指令隔离范围,但在指令中没有模板,但与指令里面的一些DOM,该指令里面的DOM无法绑定到该指令的范围。角1.2指令范围问题
<div ng-controller="testCtrl">
{{hehe}}
<hr/>
<div test-directive="hello" >
Directive Data:
<div>{{test}}</div>
</div>
</div>
angular.module('app',[])
.controller("testCtrl",['$scope', function ($scope) {
$scope.hehe = "test from controller";
}])
.directive("testDirective",function(){
return{
scope: {
"testDirective": "="
},
controller: ['$scope', function ($scope) {
$scope.test = "test from directive";
}]
};
});
在演示中,有两个角的lib版本1.1.5和1.2.4,以及它们中的一个评论。
该代码适用于1.1.5,但不适用于1.2.4。
有人可以解释发生了什么?
感谢Fabrício帮我编辑问题。让这个问题更清楚。 – areschen