0
export class PickGroupService {
  channelList: any[];
  pick5West = ['783', '679', '934', '946', '800'];
  thePicks: any[];

  constructor(private channels: ChannelsService) { this.channelList = this.channels.getChannels(); }

  getPickSet(pick, region) {
    if (pick === 'pick5') {
      switch (region) {
        case 'west':
        for (let i = 0; i < this.pick5West.length; i++) {
          this.thePicks.push((this.channelList.filter(x => x.pickCode === this.pick5West[i]));
        }
        console.log(this.thePicks);
  }
}

} } Just wondering whats wrong with this code, it says : ERROR TypeError: this_1.thePicks is undefined on browser console. Please advise!

1
  • Where and how do you call getPicks? Commented Dec 9, 2017 at 15:53

1 Answer 1

4

Initialize it to an empty array,

 thePicks: any[] = [];
Sign up to request clarification or add additional context in comments.

1 Comment

Oh wow, that was incredibly fast response. That worked! Thanks a lot.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.