🐞 bug report
Affected Package
The issue is caused by package @angular/elements
Is this a regression?
Dunno
Description
Wrong OnInit hooks call order when custom elements (parent + child) are added with some delay after (regular) angular component inited.
🔬 Minimal Reproduction
https://stackblitz.com/edit/angular-elements-init-order?file=app%2Fapp.component.html
- on toggle
> child OnInit
> parent OnInit
- same wrong order on replacing
*ngIf="visible"
with*ngIf="true"
- same wrong order on uncommenting
window.setTimeout
withinnerHTML
usage in AppComponent's OnInit hook - correct order on removing
<ng-container *ngIf="visible">
> parent OnInit
> child OnInit
🌍 Your Environment
Angular Version:
7.1.4
Anything else relevant?
No such issue with native custom elements and setTimeout
+ innerHTML
usage
https://stackblitz.com/edit/custom-elements-init-order?file=index.ts
> parent connected
> child connected
Real word use-case: adding unknown markup with custom elements from api response.
1条答案
按热度按时间jgzswidk1#
这仍然是v9的一个问题:Updated StackBlitz
奇怪的是,只有
<ng-container *ngIf="...">
出现这种情况(我们需要ng-container
和ngIf
)。我还会添加comp: core
标签,因为我不确定这是否只能在@angular/elements
中解决。