Javascript 父组件属性不为´;t角度10中输入()子组件的变化

Javascript 父组件属性不为´;t角度10中输入()子组件的变化,javascript,angular,typescript,filereader,Javascript,Angular,Typescript,Filereader,我想要在加载文档时在子组件中激发的事件。 当我在父组件中将readyToUpload设置为TRUE时(在fat arrow函数中),子组件不会检测到Input()属性的更改。。。 为什么会这样?导致脂肪箭头功能失效 child.component.ts @Input() public readytoUpload: boolean; async save() { this.getFormValidationErrors(); this.submitted.emit(); if (this.

我想要在加载文档时在子组件中激发的事件。 当我在父组件中将readyToUpload设置为TRUE时(在fat arrow函数中),子组件不会检测到Input()属性的更改。。。 为什么会这样?导致脂肪箭头功能失效

child.component.ts

@Input() public readytoUpload: boolean;

async save() {

this.getFormValidationErrors();

this.submitted.emit();

if (this.errors.length > 0) return;
if (this.frm){
  var check = async (ready: boolean) => {
    if (ready) {
      return;
    }
    setTimeout(check, 2000);
  }
  await check(this.readytoUpload);
}
inputs_to_docs(input_array: Array<any>) {
this.documents = [];
var document_count = 0;
input_array.forEach(element => {
  let doc = {};
  doc.contentType = element.files[0].type;
  doc.fileName = element.files[0].name;
  doc.fileSize = element.files[0].size;

  let reader = new FileReader();
  
  reader.onload = () => {
    
    doc.fileAsBase64 = reader.result.toString();
    
    let docs_aux: Array<any> = this.documents.slice();
    docs_aux.push(doc);
    this.documents = docs_aux;
    ++document_count;
    if (document_count == input_array.length) {
      this.readyToUpload = true;
    }
  }
  
  reader.readAsDataURL(element.files[0]);
});
parent.component.html

<app-child (submitted)="onSubmit();" [readyToUpload]="readyToUpload">

parent.component.ts

@Input() public readytoUpload: boolean;

async save() {

this.getFormValidationErrors();

this.submitted.emit();

if (this.errors.length > 0) return;
if (this.frm){
  var check = async (ready: boolean) => {
    if (ready) {
      return;
    }
    setTimeout(check, 2000);
  }
  await check(this.readytoUpload);
}
inputs_to_docs(input_array: Array<any>) {
this.documents = [];
var document_count = 0;
input_array.forEach(element => {
  let doc = {};
  doc.contentType = element.files[0].type;
  doc.fileName = element.files[0].name;
  doc.fileSize = element.files[0].size;

  let reader = new FileReader();
  
  reader.onload = () => {
    
    doc.fileAsBase64 = reader.result.toString();
    
    let docs_aux: Array<any> = this.documents.slice();
    docs_aux.push(doc);
    this.documents = docs_aux;
    ++document_count;
    if (document_count == input_array.length) {
      this.readyToUpload = true;
    }
  }
  
  reader.readAsDataURL(element.files[0]);
});
输入到文档(输入数组:数组){
本文件=[];
var文件计数=0;
input_array.forEach(元素=>{
让doc={};
doc.contentType=element.files[0]。类型;
doc.fileName=element.files[0]。名称;
doc.fileSize=element.files[0]。大小;
let reader=new FileReader();
reader.onload=()=>{
doc.fileAsBase64=reader.result.toString();
让docs_aux:Array=this.documents.slice();
单据辅助推送(单据);
this.documents=docs\u aux;
++文件计数;
if(document\u count==input\u array.length){
this.readyToUpload=true;
}
}
reader.readAsDataURL(element.files[0]);
});

}似乎是一种反模式。为什么不直接使用生命周期挂钩:
ngochanges()

ngOnChanges(){
    if (this.readyToUpload) { // ...code }
}