0

I think that I am missing something obvious but I can't quite figure this out. I am executing a promise in a controller that backs a modal dialog.

Here is the code;

$scope.elevate = ->
  $auth.authenticate('github', { auth_level: 'elevated' }).then((response) ->
    $scope.user.auth_level = 'elevated'
    return
  ).catch (response) ->
    alert response
    return

  return

The elevate function is called when the user clicks a button on the modal dialog. The code executes fine (no errors) but the promise is never resolved. The 'then' function is never called.

I read elsewhere that a call to $rootScope.$digest would do the trick but trying that just gives a "$apply already in progress" error.

Am I missing something obvious here?

Bergi
  • 630,263
  • 148
  • 957
  • 1,375
benjimix
  • 609
  • 7
  • 18
  • you tried to use a timeout? – dpaul1994 Mar 18 '16 at 12:37
  • I did. Interestingly, this just worked in Chrome (I was originally testing in Safari). So I am going to log this up to a browser issue for now (although I find that hard to believe). – benjimix Mar 18 '16 at 12:41
  • Check this out: http://stackoverflow.com/questions/16323323/promise-callback-not-called-in-angular-js – dpaul1994 Mar 18 '16 at 12:44
  • 1
    So, what's `$auth.auuthenticate`? – Bergi Mar 18 '16 at 13:03
  • The `$auth` service is the one resolving the promise. If your `.then` is not called, or intermittently called then it an issue resolving the promise, not chaining it. – ste2425 Mar 18 '16 at 13:11
  • Did `$auth.auuthenticate` return a promise? – MarkoCen Mar 18 '16 at 13:35
  • It did, yes. Also @dpaul1994 - thanks for the link. I'll take a look. I've got a feeling that this has something to do with Safari though... – benjimix Mar 18 '16 at 13:38

0 Answers0