angular - Can't fetch data from service angular2 -


my service:

private dataobs = new subject<employee>(); getdata():observable<employee>{      return  this.dataobs.asobservable(); } setdata(data: employee) {     this.dataobs.next(data); } 

my parent component looks this:

ngoninit(){     this.updatedata(this.temp) } updatedata(value: employee) {    this.parentdata.setdata(value) } 

my child component access updated data:

constructor(private parentdata:getparentdata){     settimeout(this.printdata(),200) } printdata(){     this.parentdata.getdata().subscribe(data=>console.log("display data:" , data)) } 

i'm expecting value service, i'm not able get. console.log in service() not executing..


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 -

.htaccess - ERR_TOO_MANY_REDIRECTS htaccess -