angularjs - Ionic view doesn't render ng-repeat with fetched data from API -
i trying display list of data fetched api. when page loads says errors array undefined. console prints array.
here have done far.
update.html
<ion-item ng-repeat="e in errorlist"> <ion-label>{{e.name}}</ion-label> <ion-radio value=""></ion-radio> </ion-item>
i have tried sending nav params. calling fetching function on constructor , ionviewwillenter()
update.ts
export class aboutpage { errorlist: any; error: string; errors: {}; nav: navcontroller; constructor(public navctrl: navcontroller, public navparams: navparams, private errorservice: errorserviceprovider) { this.nav = navctrl; this.error = ""; this.errors = this.navparams.get('errors'); this.errorlist = []; } ionviewwillenter() { this.fetcherrors(); } fetcherrors() { this.errorservice.geterrors() .then(data => { this.errorlist = data; console.log(this.errorlist); }); } selecterror() { console.log(this.errors); console.log(this.errorlist); } }
you doing silly mistake here, instead of ng-repeat
use ngfor
since angular, use elvis operator check value present
<ion-item ngfor="let e in errorlist"> <ion-label>{{e?.name}}</ion-label> <ion-radio value=""></ion-radio> </ion-item>
Comments
Post a Comment