【发布时间】:2021-12-18 12:49:21
【问题描述】:
我有问题(我认为是上下文),将动态组件与 ng-template 一起使用。
https://stackblitz.com/edit/angular4-wlv9rj?file=app/guidelines/guidelines.component.ts
我不明白我做错了什么,但我认为这是 Hook 的问题。
【问题讨论】:
标签: angular components ng-content
我有问题(我认为是上下文),将动态组件与 ng-template 一起使用。
https://stackblitz.com/edit/angular4-wlv9rj?file=app/guidelines/guidelines.component.ts
我不明白我做错了什么,但我认为这是 Hook 的问题。
【问题讨论】:
标签: angular components ng-content
您正在尝试在渲染#areaContainer 元素之前查询@ViewChild('areaContainer'),因为#guideline_1 模板尚未激活。这就是它未定义的原因。首先渲染#guideline_1模板,然后在里面你可以参考#areaContainer
【讨论】: