Need to implement a loading screen in Angular until an array is sorted. Solution provided below:
this.isSorting = true;
this.array = this.array.sort((a,b) => a.totlaTime - b.totalTime);
this.isSorting = false;
The issue faced is when isSorting
is set to true, it immediately becomes false. This behavior is likely due to the asynchronous nature of the .sort
function. How can I ensure that isSorting = false
only after the sorting and array population are complete?