Hi all,
in component I have prepared uploading of object in array. Before uploading of next object is timeout 20s. Before upload starts I copy the uploading object to the variable and want to show it in template. Bu *ngIf condition works only if in array is only one object. My question is, why this is happening? My code bellow.
component:
if (this.dictatesArray && this.dictatesArray.length > 0) {
this.globalTimeout = setTimeout(() => {
if (!this.showDelete) {
this.zone.run(() => {
if (this.dictatesArray && this.dictatesArray.length > 0) {
let sortedForUpload = this.dictatesArray.sort((a, b) => {
return moment(a.created).unix() < moment(b.created).unix() ? 1 : -1
})
console.log("SORTED UPLOAD ARRAY:", sortedForUpload);
this.uploadingDictate = sortedForUpload[0]
console.log("DICTATE FOR UPLOAD:", this.uploadingDictate);
console.log("===== START UPLOADING OF DICTATE: =====", this.dictatesArray[this.dictatesArray.length - 1])
this.dbP.exportDb(this.dictatesArray[0]);
this.dictatesArray.splice(0, 1);
}
});
}
}, 20000)
if (this.loader) {
this.loader.dismiss();
}
this.uploadTimeouts[this.dictatesArray[this.dictatesArray.length - 1].uuid] = this.globalTimeout
console.log(this.dictatesArray)
console.log("TIMEOUTS:", this.uploadTimeouts)
} else {
clearTimeout(this.globalTimeout);
console.log("======= TAB2 LOADER DISMISS =======")
if (this.loader) {
this.loader.dismiss();
}
template:
//current uploading object data
<ion-card *ngIf="uploadingDictate">
</ion-card>
//array of next objects for upload
<ion-card [ngClass]="{'showDelete': showDelete}" *ngFor="let d of dictatesArray">
</ion-card>