AngularJS and google cloud endpoint: walk through needed

前端 未结 3 643

I\'m new to AngularJS but I really like the way AngularJS works so I want to deployed it as client side for my Google cloud endpoint backend. Then I immediately get two prob

3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-30 17:43

    Regarding the callback - In order to access an Angular controller you need to use an injector (http://docs.angularjs.org/api/AUTO.$injector)

    Simply create a global callback function, and then get reference to the controller from it like this:

    window.callbackFunction() {
      injector = angular.element(document.getElementById('YourController')).injector()
      injector.invoke(function ($rootScope, $compile, $document) {
        $rootScope.variable = "stuff you want to inject";
      })
    }
    

    In this example I'm injecting the data to the rootScope, but this will also work for a specific controller scope (just inject $scope instead)

    Can't help with the second question as I'm not familiar with gapi, though making auth2 calls from angularjs is quite straight forward.

提交回复
热议问题