Javascript Angualrjs:隔离作用域和嵌套指令

Javascript Angualrjs:隔离作用域和嵌套指令,javascript,angularjs,Javascript,Angularjs,我被下面的问题困扰着,最终意识到它在不同版本的Angularjs中表现不同。请看小提琴 我所期望的是,包含在具有独立作用域的指令中的任何内容都只能看到该指令的$scope。在下面的示例中,嵌套了两个指令 var myApp = angular.module('myApp', []) .controller('TestController', ['$scope', function ($scope) { $scope.data = { type: "

我被下面的问题困扰着,最终意识到它在不同版本的Angularjs中表现不同。请看小提琴

我所期望的是,包含在具有独立作用域的指令中的任何内容都只能看到该指令的$scope。在下面的示例中,嵌套了两个指令

var myApp = angular.module('myApp', [])
    .controller('TestController', ['$scope', function ($scope) {
        $scope.data = {
            type: "abc",
            values: [{name:"aa"}, {name: "bb"}]
        }
}]);   
myApp.directive('directive', function () {
    return {
        scope: {
            data: "=",
        },
        restrict: 'E'
    };
});


myApp.directive('subDirective', function () {
    return {    
        template: '<div>Data: {{data}}</div>',
        restrict: 'E'        
    };
});
但是,转换是否可以用来实现这一点呢。不知道为什么评论中的@allenhwkim fiddle不起作用。
谢谢。

玩了你的小提琴。没有transclude的指令中的元素对我来说是新的。隔离作用域现在实际上是隔离的。查看此提交:
<div ng-controller="TestController">
    <directive data="data.values">
        <sub-directive></sub-directive>
    </directive>
</div>
1.2.0 timely-delivery (2013-11-08)
$compile:
don't leak isolate scope state when replaced directive is used multiple times (b5af198f)
correct isolate scope distribution to controllers (3fe4491a)
replaced element has isolate scope (97c7a4e3)
only pass isolate scope to children that belong to the isolate directive (d0efd5ee)
make isolate scope truly isolate (909cabd3, #1924, #2500)