rxjs - Angular 2 Observable.forkJoin results -
i have following code in component:
public user: user; public roles: role[]; public organizations: organization[]; public ngoninit() { this.user$ = this.userservice.getuser(1).share(); this.roles$ = this.roleservice.getroles().share(); this.organizations$ = this.organizationservice.getorganizations().share(); observable.forkjoin([this.user$, this.roles$, this.organizations$]).subscribe(data => { this.user = data[0]; this.roles = data[1]; this.organizations = data[2]; }); }
this should work think getting error in idea , wont compile, stuck on time now, can help?
service methods looks this:
public getroles(): observable<role[]> { return this.http.get(this.api_url).map(res => res.json()); }
Comments
Post a Comment