I know that there are several questions about this point. I have a table and for each row I've a button to show row's details with a modal, so I need to call a function to initialize these buttons when ngFor has finished to render them. This external function will add listeners "onClick" to every button to open modal, sadly I can't edit this external function anyway.
ngFor
is synchounous, so as soon as the ngForOf
array is updated during the ngDoCheck
lifecycle it will render all items. So you can safely use ngAfterViewChecked
in the parent component to perform your logic. When this lifecycle hook is triggered ngFor
has added items to the DOM.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.