typescript - Ionic3, Angular 2, rxjs object assign page variable -


i doing ionic3 project. , here's question. back-end : used rxjs firebase simple , nice realtime data. front code here:

i want data keep consistency. made service brings data , assign each page variable this.

[.ts file]

public dogmodel = new dogmodel(); constructor( ,public testservice: testservice) { this.dogmodel = this.testservice.dogmodel; } 

[html file]

<div>{{dogmodel.state}}</div> 

and works well. when data changed in service, don't know how service data re-assign page variable @ all. , 1 more, if change code this,

this.dogmodel.state = this.testservice.dogmodel.state; 

i can see log changing data in service, couldn't see change in page. know this?

part of service.ts

constructor(       public db: angularfiredatabase   ) {     db.object( this.firebaseurl + '/dogstate/test1234')       .subscribe( (dogstate) => {         object.assign(this.dogmodel, <dogmodel>dogstate);          console.log(this.dogmodel);       }); 

i imagine changes fed ui because of events firing listened to. i'm assuming talking updating data in firebase console, , app shows changes on screen of ionic app. beauty of subscribe! using reactiveformsmodule right?


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -