I'm struggling with retrieving the subscribe array in NG2.
Being new to typescript, I find it difficult to understand how to pass variables between functions and constructors.
This is what my code currently looks like:
export class RosterPage extends Page {
roster:Roster[];
players:Players[];
roster_data:any;
constructor(private location: Location, private playersService: PlayersService) {
super(location);
this.players = [];
this.roster = [];
this.roster_data = this.getRoster();
for (let i of this.roster_data) {
console.log(i); // I need to iterate through
}
getRoster() {
return this.playersService.getRoster("2017","MUZ").subscribe(roster => {
this.roster = roster["soupiska"];
});
}
}