ngFor unable to parse JSON Object Ionic 3

时间:2018-06-04 17:35:31

标签: ionic3

I´m trying to parse a JSON Object, which I get from an API. Unfortunately I cannot bind the data. I get no error, but no data appear. The alert shows a successful request to the api. (ionic3, Angular 6.0.0)

home.html

 exported class: diagnoses : any;

 <ion-item *ngFor="let diagnose of diagnoses">
          <p>Diagnose: {{diagnose.additionalParameters.dictCanon}}</p>
          <p>ID: {{diagnose.additionalParameters.uniqueId}}</p>
 </ion-item>

home.ts

startPipeline() {

    var text = 'Appendizitis';
    this.restProvider.getDiagnoses(text)
        .subscribe(
        function(response) {

                //alert("Success Response" + response);
                this.diagnoses = JSON.stringify(response.annotationDtos);
                alert(this.diagnoses);
            },
            function(error) { 
                alert("Error happened" + error)
            },
            function() { 
                //alert("the subscription is completed")
            }        
            );

}

rest.ts

getDiagnoses(text): Observable<any> {
return this.http.post(this.apiUrl, text, httpOptions);
    }
}

1 个答案:

答案 0 :(得分:0)

just: this.diagnoses = response.annotationDtos