我试图找出一种方法来使用transclusion从顶级祖先组件为深层嵌套组件提供模板。可以重用该组件树的想法,但可以根据用途自定义最低级别组件的标记。我似乎找不到通过多个组件传递内容的方法。
<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>'
});