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
Post a Comment