fix(schematics): use ngAfterViewInit instead of ngOnInit in table - #15446
Conversation
According to the offical doc of Angular, view queries are set before the ngAfterViewInit callback is called.
There was a problem hiding this comment.
Good catch. This right now works as the queries are considered as static by the Angular compiler.
Also it's brittle to make this assumption in a schematic as it's not guaranteed to be always static. e.g. if someone adds a ngIf, the query turns dynamic.
LGTM from my side. waiting for Andrew to also have a look.
|
This looks fine since data is not set before view initialization. If it was, the table would render all the rows before view initialization is complete, and then correct itself after the sort/paginator is set. |
|
@andrewseguin is that a formal approval? |
|
Yes it is - added the labels |
…5446) According to the offical doc of Angular, view queries are set before the ngAfterViewInit callback is called. https://angular.io/api/core/ViewChild ngOnInit works with the current version of Angular, but it can change in the future.
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
According to the offical doc of Angular, view queries are set before the ngAfterViewInit callback is called.
https://angular.io/api/core/ViewChild
ngOnInit works with the current version of Angular, but it can change in the future.