title: angularjs pass anonymous function through ng-click
body: <p>I am using AngularJS and would like to pass an anonymous JavaScript function from an html element's <code>ng-click</code> function as a parameter to a function on my scope.</p>
  <pre><code>&lt;div ng-app=&quot;&quot;&gt;
    &lt;div ng-controller=&quot;Ctrl1&quot;&gt;
        &lt;button ng-click=&quot;test(function(){alert('pushed');})&quot;&gt;Push Me&lt;/button&gt;
    &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  <p>And then in JavaScript:</p>
  <pre><code>function Ctrl1($scope) {
      $scope.test = function(callback){
          callback();
      };
  }
  </code></pre>
  <p>I have setup up a simple jsfiddle to demonstrate the problem:
  <a href="http://jsfiddle.net/C4t4LystX/gUj8x/4/" rel="nofollow noreferrer">http://jsfiddle.net/C4t4LystX/gUj8x/4/</a></p>
  <hr />
  <p>Whenever I try and do this in my code I get this type of error in the console:</p>
  <p><code>Syntax Error: Token '{' is unexpected, expecting [)]</code></p>
  <p>How should I perform this?</p>