Angular - Making an API call for ng-hide/show - Bad idea?

I have a button that i want to show/hide depending on whether a user has posted on an item before. To find this out I've written an API call which returns true or false.

However whenever I use this is my code, I keep getting the:

Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting! error.

Why would my code be doing this and is the general way I've implemented this the correct way to go about this?

My code looks like:

<div ng-show='main.hasPosted()'>The Button To Go In Here</div>

And in the controller:

self.hasPosted = function() {
      $http.get(API + '/hasPosted', {
         headers: {
           itemtocheck: $routeParams.id
         }
       }).
       then(function(result){
         return result.data.success;
});

Answers


<div ng-show='showButton'>The Button To Go In Here</div>

self.hasPosted = function() {
      $http.get(API + '/hasPosted', {
         headers: {
           itemtocheck: $routeParams.id
         }
       }).
       then(function(result) {
$scope.showButton = result.data.success;
});

Need Your Help

IbPy cant send order - must specify an account

python ibpy

Im trying to use the following code to try an send an order to TWS to place on google shares. I do not understand why it keeps on asking for an account, I have TWS open and have checked enable Acti...

SurfaceView hiding automatically

android

I am having a glview and a surface view. What i have done is that i have created a relative layout and add both views on that relative layout. Everything is working fine. My glview is at back and my