title: Angular: ReferenceError: 'function' is not defined
body: <p>I have a simple <a href="https://embed.plnkr.co/mT7RTQZhAzxnXeFxKVoi/" rel="nofollow noreferrer">Plunkr</a> app that adds two numbers together on the click of a button.</p>
  
  <p>I am getting a <code>ReferenceError: addNumber is not defined</code> where add number is a function that is called by the 'onClick' handler.</p>
  
  <pre><code>onClick(num1, num2){
    addNumber(num1, num2).then((result) =&gt; this.result = result));
  }
  
  addNumber(x, y){
    return new Promise((resolve) =&gt; {
            x = parseInt(x);
            y = parseInt(y);
            setTimeout(() =&gt; resolve(x+y), 2000)
          })
        }
      }
  </code></pre>
  
  <p>However, if I add the <code>function</code> keyword to <code>addNumber</code> it works but as I understand it, with Typescript it is optional to use the <code>function</code> keyword.</p>
  
  <p>Why is addNumber not defined when the button is clicked?</p>