1
非常感謝這個問題,這個問題是當我使用transclude指令時,角度子範圍沒有從父範圍繼承,這個問題與angular.js版本有關係,在1.2.17之前可以工作發佈版本1.2 .18之後無效爲什麼angular.js transclude child child不會繼承parentScope?
這些是實際測試結果的兩個版本。 http://jsfiddle.net/a3ywb2c4/
var App= angular.module("myApp",[]);
App.controller("testCtrl",function($scope){
$scope.names= [{name:"janry",value:123},{name:"janry",value:123},{name:"janry",value:123}]
$scope.dd="hello world"
});
App.directive("testDire",function($parse){
return {
restrict:'A',
transclude:true,
template:"<div ng-repeat='$item in $items' ng-transclude></div>",
scope:false,
link:function(scope,iele,attrs,ctrl,transclude){
var getter=$parse(attrs.data)
scope.$items = getter(scope);
}
};
})