简体   繁体   中英

How to force view update in middle of code execution?

Every once in a while I have a situation where my code changes some variable binded to the view, or even change some attribute of a Dom element, but the view renders only when all the code is executed, when I usually I don't need the effect anymore, like for example an animation for an Ajax data load.

Is there a way or a command that forces the DOM or Angular to revalidate its bindings or simple refreshes the view?

If I understand your problem correctly it looks like you need to run change detection manually.

ChangeDetectorRef.detectChanges() would trigger change detection for view and child components.

ChangeDetection Docs

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM