angular - Ionic 3 not updating view -


hi got function update after http request server. seems console.log show value has been updated ui not updating unless click on other component(ex. input).

this function:

filetransfer.upload(this.created_image, upload_url, options) .then((data) => {     console.log("success:"+data.response); //this showing correct response     var obj = json.parse(data.response);     this.sv_value = obj.value;     console.log(this.sv_value); //this showing correct value }, (err) => {     console.log("failure:"); }) 

this view html:

    <ion-row>       <ion-col center width-100 no-padding>         <h2>{{sv_value}}</h2> //this not updated       </ion-col>     </ion-row> 

is there way can tackle issue? thank you

try placing this.sv_value = obj.value; inside ngzone.run(); make angular detect change.

import { component, ngzone } "@angular/core"; ...  export class mycomponentpage {     constructor(         private zone: ngzone         ...     ){ }      yourfunction(){         filetransfer.upload(this.created_image, upload_url, options)         .then((data) => {             console.log("success:"+data.response); //this showing correct response             var obj = json.parse(data.response);              this.zone.run(() => {                 this.sv_value = obj.value;             });              console.log(this.value); //this showing correct value         }, (err) => {             console.log("failure:");         });     } } 

Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -