title: AngularJS ng-click and callback function
body: <p>On my web application, there are two kinds of users: guests &amp; logged. The main page loads the same content for each.</p>
  
  <p>My goal :</p>
  
  <ul>
  <li>When a registered user clicks the link, 2 ajax requests ($http) retrieve
  the data of another page and load them in a model.</li>
  <li>If the user is a guest, another model appears saying that he has to register.</li>
  </ul>
  
  <p>My link :</p>
  
  <pre><code>&lt;h4 ng-click="guestAction($event, showOne($event,card.id));"&gt;click me&lt;/h4&gt;
  </code></pre>
  
  <p>GuestAction :</p>
  
  <pre><code>$scope.guestAction = function($event, callbackB) {
  
      $http.get('/guest/is-guest/').success(function(data) {
          console.log("isGuest retrieved : " + data);
          if (data == 1)
          {
              alert('guest spotted !');
              return false;
          }
          else
          {
              alert('user');
              console.log(callbackB);
              eval('$scope.'+callbackB);
          }
  
      });
  
  }
  </code></pre>
  
  <p>This way, if a guest is spotted, we return false and stop the execution. If it's a regular user, we execute the function showOne. As I want to do 2 asynchronous requests one after the other, I chose to use the callback trick.</p>
  
  <p>The problem is that <code>showOne()</code> is executed directly when ng-click is launched. I tried to pass <code>showOne()</code> as a string, and <code>eval()</code> the string in <code>GuestAction</code>, but the parameters become undefined...</p>
  
  <p>Any idea how to solve this problem? I want to use a generic method which fires a function only if the user is logged.</p>