title: AngularJS pass string as function to use at ng-click
body: <p>I want to assign a javascript function to ng-click which name is sourced by a rest service.</p>
  
  <pre><code>&lt;li ng-class="{ active: isActive('url')}" data-ng-repeat="menu in mb.data"&gt;
     &lt;a href="{{menu.href}}" data-ng-click="{{menu.javascript}}"&gt;{{menu.label}}&lt;/a&gt;
  &lt;/li&gt;
  </code></pre>
  
  <p>Sadly the angularjs parser throws an exception if one use {{ }} inside of ng-click. So I have tried several workarounds like using a callback function</p>
  
  <pre><code>  &lt;a href="{{menu.href}}" data-ng-click="call(menu.javascript)"&gt;{{menu.label}}&lt;/a&gt;
  </code></pre>
  
  <p>But none of my ideas succeeded. How can I assign a javascript functions name in ng-lick? Btw. the function itself is part of the $scope.</p>
  
  <p>Edit- Here is the controller:</p>
  
  <p>The "$menu" service is simply a get rest request. The request result is a json object and only holding string values. In the current issue the result for menu.javascript is "loginModal()".</p>
  
  <pre><code>.controller('HeaderController', function($scope, $http, ModalService, $menu, $routeParams) {
      $scope.loginModal = function() {
          console.log("modal", ModalService);
          // Just provide a template url, a controller and call 'showModal'.
          ModalService.showModal({
              templateUrl: "/modals/login.modal.html",
              controller: "LoginController"
          }).then(function(modal) {
              // The modal object has the element built, if this is a bootstrap modal
              // you can call 'modal' to show it, if it's a custom modal just show or hide
              // it as you need to.
              console.log(modal.element);
              modal.element.modal();
              modal.close.then(function(result) {
                  console.log(result ? "You said Yes" : "You said No");
              });
          });
      };
  
      $menu.get($routeParams, function(data){
          $scope.menu = data;
      });
  })
  </code></pre>
  
  <p>Edit 2:</p>
  
  <p>Interestingly when I use {{menu.javascript}} then the correct string "loginModal()" is available in the DOM. But the angular parser stopped there due to errors.</p>