单个元素上的多个指令 - 如何解析范围?

时间:2014-07-14 14:42:50

标签: angularjs

我有以下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示例。

以下是我想知道答案的问题列表:

  1. 传递给scope函数的link是否为directiveIsolateScope ng-repeat是由。创建的独立范围 指示?如果是这样,为什么它具有由scope创建的范围 指令作为父母?
  2. 传递给link directiveNewChildScope函数的ng-repeat是否是指令创建的子范围? 范围是否继承自{{1}}创建的范围?我想 这里没有发生任何改变。
  3. 创建传递给这些指令的作用域的时间和位置?

0 个答案:

没有答案