2

我正在尝试从顶级祖先组件中找出一种使用嵌入为深层嵌套组件提供模板的方法。这个组件树的想法是可以重用的,但最低级别组件的标记可以根据使用进行定制。我似乎找不到通过多个组件传递内容的方法。

<parent-component>
  <h2>{{ grandchild.title }}</h2>
</parent-component>

angular.module('parent', ['child']).component('parentComponent', {
  template: '<child-component></child-component>',
  transclude: true
});

angular.module('child', ['grandchild']).component('childComponent', {
  template: '<grand-child-component></grand-child-component>'
});

angular.module('grandchild', []).component('grandChildComponent', {
  template: '<div>How to get transcluded content with correct context here?!?</div>'
});
4

0 回答 0