The change detection works in the following scenarios where the data changes needs to update the application HTML.
-
Component initialization: While bootstrapping the Angular application, Angular triggers the
ApplicationRef.tick()
to call change detection and View Rendering. - Event listener: The DOM event listener can update the data in an Angular component and trigger the change detection too.
- HTTP Data Request: You can get data from a server through an HTTP request
- Macro tasks setTimeout() or setInterval(): You can update the data in the callback function of setTimeout or setInterval
- Micro tasks Promises: You can update the data in the callback function of promise
- Async operations like Web sockets and Canvas: The data can be updated asynchronously using WebSocket.onmessage() and Canvas.toBlob().