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.
But this seems not to work. Let's have a look at the code:
<div class="padding20" ui-view="create-event-form" ng-controller="detailedViewController" ng-init="loadDetails()">
<button type="submit" class="button success" ng-if="getParticipationStatus(eventDetails._id)">Participate on this event!</button>
As you see, I access inside by ng-if a method from my detailedViewController. The detailedViewController contains the following method:
$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 > 0) {
for (i = 0; i < hostingList.length; i++) {
if (hostingList[i]._id == eventId) {
participationStatus = true;
} else {
participationStatus = false;
}
}
return participationStatus;
}
}
} );
};
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:
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&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)
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.
Any help appreciated! Thanks in advance.