其他分享
首页 > 其他分享> > 父组件子组件之间传值(父组件异步获取api传值)

父组件子组件之间传值(父组件异步获取api传值)

作者:互联网

父组件

<app-hct-patient-page-eligibility [patientProfileSurvey]="patientProfileSurvey" [plaquePsoriasisSurvey]="plaquePsoriasisSurvey"></app-hct-patient-page-eligibility>

子组件

  @Input() patientProfileSurvey:any;

ngOnChanges(changes:SimpleChanges){
    //get patientProfileDatas
    if(changes["patientProfileSurvey"]!=undefined){
      if(changes["patientProfileSurvey"].currentValue.length){
        changes["patientProfileSurvey"].currentValue=changes["patientProfileSurvey"].currentValue.sort((a, b) => b.scheduledDateTime.localeCompare(a.scheduledDateTime))  //get the latest data
        this.profileSurveyArray=changes["patientProfileSurvey"].currentValue[0];
        this.profileSurveyArray=this.profileSurveyArray["surveyQuestionsResponses"].filter(element=>element["externalQuestionID"]=="37034")
        this.criteriaDatas=this.criteriaDatas.concat(this.profileSurveyArray)
      }
    }
  
  }

 

标签:currentValue,patientProfileSurvey,api,profileSurveyArray,组件,scheduledDateTime,ch
来源: https://www.cnblogs.com/jahoon/p/15935634.html