In one angular component, I am trying to put progress spinner over data loading. User click on html button and below function executes. Array filter may take some time depending upon array size. I want variable isLoading to be true in the beginning and false when filter function is completed. Variable isLoading is used to show/hide progress spinner.
myfunction(val){
this.isLoading = true
var data = this.myarray.filter(function(item) {
// this.isLoading = false // tried this, throws error - Cannot set property 'isLoading' of undefined
return item.name == val;
});
this.showdata = data[0]
// this.isLoading = false // tried this, but this does not show effect
}
Please suggest, how to handle this. Thanks