title: How to call a function on the scope from a string value
body: <p>I have an object containing an array of strings</p>
  
  <pre><code>$scope.actions=[
      "add_inscription",
      "add_tools",
      "add_instruction",
      "remove_inscription",
      "remove_tools",
      "remove_instruction"
  ];
  </code></pre>
  
  <p>and I would like to be able to do dynamic action calls through a delegating function..</p>
  
  <pre><code>$scope.delegate = function () {
  
      var arg = arguments[0];
  
      for ( key in $scope.actions ) {
  
          if ($scope.actions[key] == arg ) {
  
              // call function that has a matching name
  
          }
      }
  }
  </code></pre>
  
  <p>So in my template I have something like this</p>
  
  <pre><code>&lt;button ng-click="delegate('add_inscription')"&gt;Add Inscription&lt;/button&gt;
  </code></pre>
  
  <p>I don't know if I am thinking in the right direction with this either,, but the point is that my actions object is actually pretty large and I don't want to write massive switch case statement that I will have to update all the time. </p>
  
  <p><strong>Is there a way to do this in angular?</strong></p>
  
  <p>I have no problem doing this in <strong>straight up javascript</strong> </p>
  
  <pre><code>var fnstring = "add_inscription";
  
  // find object
  var fn = window[fnstring];
  
  // if object is a function
  if (typeof fn === "function") fn();
  </code></pre>
  
  <p>but in angular I can't get this done..</p>