Discussion for angular (2+) - need help? create a stackblitz with your issue to get help faster using this template: https://stackblitz.com/fork/angular-issue-repro2
class SomeComponent {
constructor(someService: SomeService){
someService.doStuff().subscribe(...)
}
}
export class AppComponent implements OnInit{
public selectedHero: Hero;
public heroes: Hero[];
result: Object;
constructor(private _heroService: HeroService) { }
onSelect(hero: Hero) { this.selectedHero = hero; }
ngOnInit() {
this.getHeroes();
this.getFriends();
}
getHeroes() {
this._heroService.getHeroes().then(heroes => this.heroes = heroes);
}
getFriends(){
this.result = {friends:[]};
this.result =this._heroService.loadFriendsSuccessFully().subscribe(res => this.result = res);
}
}