Angular 1.6 $ http.jsonp when using google APIs

Angular 1.6 $ http.jsonp does not play well with google APIs:

I am trying to extract and then retrieve data from google sheets, with the following:

var callback;
app.controller("meetingsTable", function ($scope, $http, $sce) {

var url = "http://spreadsheets.google.com/a/google.com/tq";
var trustedUrl = $sce.trustAsResourceUrl(url);
var key = 'MY_KEY';
var tq = 'select%20*%20limit%2010';
var tqx = 'responseHandler:callback';
var params = {
    key: key,
    tq: tq,
    status: 'ok',
    tqx: tqx
};

callback = function (response) {
    console.log(response); // entering here, not to the promise
    return response;
}


    $http.jsonp(trustedUrl, { params: params }).then(function (response) {
        console.log(response);
        retrun;
        //success things go here
    }, function (response) {
        //error things go here
    });
});

I successfully worked to get data from sheets using a function (callback) using vnila js, when I tried using angular, I got google.visualization.Query.setResponse object in Sources, with console error: Not prepared ReferenceError: google not determined.

The most unpleasant thing is that a promise does not receive a response, and I cannot update my ansyc table values. I tried everything I could come up with (and every suggestion on stackoverflow), Things I tried:

  • passing url as is, without parameters, cuase myabe $ sce.trustAsResourceUrl needs a full url.
  • $sce ( vanila js, ).
  • " ".
  • , API ( , ).
  • " " , .
  • jsonp , , & .
  • "tqx = responseHandler: callback" togther.
  • tqx.
  • 1,5 < "JSON_CALLBACK", 1.6.
  • vanila js, ( ).

, .

, - , ? , , .

+6
1

:

, angular $scope. $apply . API angular, guide $$, . :

$scope.tableContentData;
callback = function (response) {
    $scope.$apply(function () {
        $scope.tableContentData = response;
    });
};
$http.jsonp(trustedUrl).then(function () {
        //success stuff
    }, function () {
        //error stuff
    });

.

.

! !

+1

All Articles