I have a variable in a component below and i want to use it in anther component. how to do that?
public uploadFile = (files:any) => {
if (files.length === 0)
return;
let fileToUpload = <File>files[0];
const formData = new FormData();
formData.append('file', fileToUpload, fileToUpload.name);
this.http.post('https://localhost:5001/api/upload',
formData, {reportProgress:true, observe: 'events'})
.subscribe(event =>
{
if (event.type === HttpEventType.UploadProgress){
this.progress = Math.round(100 * event.loaded / event.total);
}
else if (event.type === HttpEventType.Response){
this.message = "Upload is success";
this.onUploadFinished.emit(event.body);
}
});
}
the variable name is fileToUpload.name and i want to use it in another component not just receive it.