I would like to show the progress bar in my template, but the uploading is happened through service called through component. I am stuck to send the progress bar from service to component.
Here is my snippet
My file custom.service.ts
import {Injectable} from '@angular/core';
@Injectable({
providedIn: 'root'
})
export class CustomService {
constructor() {}
upload(fileScope, $files, callback) {
let progress = 1;
setTimeout(function() {
progress++;
// Send progress to the component
}, 500);
}
}
Component
this.progress = 0;
this.customService.upload(this.tickFile, file, function (err, data) {
if (data) {
// Application logic
}
}.bind(this));
Any suggestion to fix it? Thanks