I have four components, the parents componets.html looks like
<div class="main">
<div class="column-left">
<app-document-info></app-document-info>
</div>
<div class="column-center" style="float:left">
<app-document-scan></app-document-scan>
</div>
</div>
Document-Scan component also contains component inside this is some snippet code for that component (Document-Nested)
<div class="btnGrp">
<input type="file" name="img" multiple (change)="onChange($event)">
</div>
public onChange(event: Event) {
this.loadFiles();
};
loadFiles() {
let files = event.target['files'];
this.allFiles = files.length;
for (var i = 0; i < files.length; i++) {
let fileReader = new FileReader();
fileReader.onload = () => {
let infoFile: string = fileReader.result;
let obj: fileStructure = {
name: files[this.loadedFiles].name,
data: fileReader.result,
type: files[this.loadedFiles].type
}
this.listImages.push(obj);
this.loadedFiles++;
this.loadImage();
}
if (fileReader && files && files.length) {
fileReader.readAsDataURL(files[i]);
}
}
}
loadImage() {
this.imageService.setImages(this.listImages);
this.imageLoadedEvent.emit(this.isClickedFileUploader);
}
My component Document-info i have some method that I would execute when method loadFiles() from document-scan is finished or pass data to this component that i inject in loadImage() method using service
This is my service
export class ImageService {
isClicked: boolean = false;
listImages: fileStructure[] = [];
bodyContent;
setBodyRes(res) {
this.bodyContent = res;
}
getBodyRes() {
return this.bodyContent;
}
setImages(imageList: fileStructure[]) {
this.listImages = imageList;
}
getImages(): fileStructure[] {
return this.listImages;
}
}
How to pass data or inform some method that finish execute between component Document-Nested that is inside Document-Scan and Document-Info. Document-Scan and Document-Info are sibling ?