当元素位于模态内部时,Angular ViewChildren 不起作用

Dav*_*sov 5 javascript ng-bootstrap angular

当模板引用变量放置在模态中时(因此最初未定义),我无法使用 ViewChildren 访问模板引用变量。即使在将模态插入到 DOM 中之后,元素的 QueryList 的长度仍然为零。

  1. 我尝试注入 ChangeDetectorRef 然后使用 detectorChanges() 手动检测更改
  2. 我尝试过为 ViewChildren 使用 setter

这里的最小可重现示例: https ://stackblitz.com/edit/angular-whsdr6

对于上面的示例,我希望 console.log 返回一个对象,其结果属性是长度为 5 的数组(五个段落标记元素)。