title: How to invoke a function as dynamically string in AngularJS?
body: <p>How to use a <em><code>function assigned variable</code></em> in <code>ng-click?</code>? I have tried <strong>three</strong> ways below, but that's also not working. </p>
  
  <p>Could you please let me know is it possible or not??? if yes, then how?</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var app = angular.module("app", []);
  app.controller("name", function($scope) {
  
   $scope.showname = function()
   {
   alert("Ramesh");
   }
   
   $scope.variable1 = $scope.showname;
    
   $scope.variable2 = "showname()";
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"&gt;&lt;/script&gt;
  &lt;div ng-app="app" ng-controller="name"&gt;
  &lt;button type="button" ng-click="variable1" tabindex="10003" &gt;Not working 1 &lt;/button&gt;
  
  &lt;button type="button" ng-click="$scope[variable2]()" tabindex="10003" &gt;Not working 2 &lt;/button&gt;
  
  &lt;button type="button"  ng-click="variable2" tabindex="10003" &gt;Not working 3 &lt;/button&gt;
  
  &lt;button type="button" ng-click="showname()" tabindex="10003"&gt; working &lt;/button&gt;
  &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>