ng-if resulting in an infinite loop
<p>First a brief description of what I want to do: I want to iterate through the elements of an array and displaying its content. Based on the information I get from the element inside the array, I want to show a button- or not. </p>

<p>But this seems not to work. Let's have a look at the code:</p>

<pre><code>&lt;div class="padding20" ui-view="create-event-form" ng-controller="detailedViewController" ng-init="loadDetails()"&gt;
 &lt;button type="submit" class="button success" ng-if="getParticipationStatus(eventDetails._id)"&gt;Participate on this event!&lt;/button&gt;
</code></pre>

<p>As you see, I access inside by ng-if a method from my detailedViewController.
The detailedViewController contains the following method:</p>

<pre><code>$scope.getParticipationStatus = function( eventId ) {
    var userName = cookieUserManagement.getUsername();
    userClient.getUserEvents( eventId, userName, function ( success, hostingList ) {
        var i = 0;
        var participationStatus;
        if ( success ) {
            hostingList = hostingList.ownEvents;
            if (hostingList.length &gt; 0) {
                for (i = 0; i &lt; hostingList.length; i++) {
                    if (hostingList[i]._id == eventId) {
                        participationStatus = true;
                    } else {
                        participationStatus =  false;
                    }
                }
                return participationStatus;
            }
        }
    } );
};
</code></pre>

<p>And now the problem: All parameters are handled in a correct way. I see the right ID's, right objects, everything seems to be correct. But this piece of code results in a endless loop (i.e. put in an alert and enjoy never ending alerts from your browser) and the following error message:</p>

<pre><code>angular.js:13642TypeError: callback is not a function
at services.js:374
at angular.js:16104
at m.$eval (angular.js:17378)
at m.$digest (angular.js:17191)
at m.$apply (angular.js:17486)
at l (angular.js:11637)
at D (angular.js:11843)
at XMLHttpRequest.w.onload (angular.js:11776)(anonymous function) @ angular.js:13642


angular.js:13642Error: [$rootScope:infdig] http://errors.angularjs.org/1.5.6/$rootScope/infdig?p0=10&amp;p1=%5B%5D
at Error (native)
at http://127.0.0.1:3000/node_modules/angular/angular.min.js:6:412
at m.$digest (http://127.0.0.1:3000/node_modules/angular/angular.min.js:143:281)
at m.$apply (http://127.0.0.1:3000/node_modules/angular/angular.min.js:145:401)
at l (http://127.0.0.1:3000/node_modules/angular/angular.min.js:97:250)
at D (http://127.0.0.1:3000/node_modules/angular/angular.min.js:101:373)
at XMLHttpRequest.w.onload (http://127.0.0.1:3000/node_modules/angular/angular.min.js:102:397)
</code></pre>

<p>As far as I see, I have declared everything in a right way. But I don't know why this is resulting in an endless loop.</p>

<p>Any help appreciated! Thanks in advance.</p>