Note that there are some explanatory texts on larger screens.

plurals
  1. POCalling Angular service from outside JS via .scope().call() hangs request
    primarykey
    data
    text
    <p>I'm working on adding a Google+ signin button to my Angular app and most of it is working, except for the handling of the callback result. The callback from the G+ signin is an outside JS function called <code>signinCallback</code> with looks like so:</p> <pre><code>//Handling the Google+ Signin right here function signinCallback(authResult) { angular.element($("#btnGooglePlus")).scope().handleGoogleSignin(authResult); } </code></pre> <p>The only way I could figure out how to pass the <code>authResult</code> back into the controller was to call a controller method via <code>element.scope()</code>. <code>handleGoogleSignin</code> is called fine, and inside that function there is a <code>http.get</code> service call that looks like:</p> <pre><code>User.getSocialKey(key).then(function(data) { console.log(data); }); </code></pre> <p><code>User</code> is a service, and <code>getSocialKey</code> looks like:</p> <pre><code>getSocialKey: function(etag) { console.log("Hit the social key service with the etag: " + etag); return $http({ url: '/api/user/social', method: 'post', data: {etag:etag} }).then(function(result) { console.log("Returning promise from social service"); return result.data; }); }, </code></pre> <p>The first log statement gets hit fine, then nothing. Request is never sent. Now, if I go and click something on the page that has an <code>ng-model</code> attribute (example, a checkbox), the request is then sent and received just fine. So my question: <strong>Why is my Angular service call being suspended until I click on something? Why isn't it going through right away?</strong></p> <p>I've tried replacing <code>getSocialKey</code> with working service calls, same thing. I believe the issue comes down to calling the function with <code>angular.element($("#btnGooglePlus")).scope().handleGoogleSignin(authResult);</code> but I'm not sure. Anyone seen this before?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload