title: TypeScript function calls and returning data
body: <p>I am learning Ionic and I have the following function:</p>
  
  <pre><code>loadPaper(paper){
    this.testFunc();
  
      console.log('questions', this.questions);
      console.log('paper', paper);
  
      this.navCtrl.push(this.loadPaperPage, {
          paper: paper,
          questions: this.questions
      });
  
  }
  
  testFunc(){
    this.papersData.getPaper().subscribe(questions =&gt; {
      this.questions = questions.questions;
    });
  }
  </code></pre>
  
  <p>My loadPaper function calls <code>testFunc()</code> in order to setup a global variable with required data. I then attempt to use the data in a <code>console.log</code> print but the console reports the data is <code>undefined</code> instead of the json data I was expecting.</p>
  
  <p>Aside from the fact it does not work, I am sure it's not the best solution. I did try my preferred and standard solution of <code>return</code>ing data from the second function but that failed to work.</p>
  
  <p>How can I resolve this?</p>