I'm trying to implement a progress bar that moves in accordance with a process that's running in my Angular program.
<div mat-dialog-content>
<mat-progress-bar mode="determinate" [value]="loadingVal"></mat-progress-bar>
</div>
var loadingVal = 0
var increase = 100 / array.length
for (i = 0, array.length, i++) {
....
this.loadingVal = this.loadingVal + increase
}
As you can see, I am increasing the loadingVal with every iteration of the loop. However, the progress bar is not moving, it is staying at 0 until the process is complete. Am I doing something wrong, or is there another way to move the progress bar along?

window.setTimeout(() => this.loadingVal += increase, 500 * i);within your loop. ThesetTimeout()function will queue those callbacks and Angular can perform the change detection inbetween. BTW: Try to write your for-loop this way:for (let i = 0; i < array.length; i++) { ... }this.loadingVal = this.loadingVal + increasebywindow.setTimeout(() => this.loadingVal += increase, 500 * i);. Note: The second argument tosetTimeout()is the time (in milliseconds) after which the callback should be called. I only used it here to slow down the progress bar animation.loader = 20and feeding that to the HTML and it still won't show. I think it is not passing value from TS to HTML..?