我有以下html:
<body ng-controller="MainCtrl">
<span directive-isolate-scope ng-repeat="word in words">{{word.name}}<br></span>
<span directive-new-child-scope ng-repeat="word in words">{{word.name}}<br></span>
</body>
以下是js:
angular.module('plunker', [])
.controller('MainCtrl', function($scope) {
$scope.words = [
{name:'Ben'},
{name:'Anna'}
]
})
.directive('directiveNewChildScope', function(){
return {
scope: true,
link: function link(scope, element, attrs) {
debugger;
}
}
})
.directive('directiveIsolateScope', function(){
return {
scope: {},
link: function link(scope, element, attrs) {
debugger;
}
}
});
Here is Plunker示例。
以下是我想知道答案的问题列表:
scope
函数的link
是否为directiveIsolateScope
ng-repeat
是由。创建的独立范围
指示?如果是这样,为什么它具有由scope
创建的范围
指令作为父母?link
directiveNewChildScope
函数的ng-repeat
是否是指令创建的子范围?
范围是否继承自{{1}}创建的范围?我想
这里没有发生任何改变。