title: Why can't I define inline functions inside Angular templates ? How else to do it?
body: <p>I'm using Angular 2 and is new to it. I wanted to invoke a small function for a button click. So I tried doing this (maybe bcos I come from a React background):</p>
  
  <pre><code>&lt;button class="btn btn-primary" (click)="(() =&gt; { console.log('hi') })()"&gt;
    Click Me
  &lt;/button&gt;
  </code></pre>
  
  <p>I used an IIFE for the <code>(click)</code> attribute. But it didn't work. Why does it not work, and is there any other way to declare an anonymous function and invoke it upon button click ?<br>
  What I actually want to do is assign a value like so: <code>(val) =&gt; { value = val }</code></p>