GAPAngular is javascript librairie. It helps AngularJS developpers to connect to Google EndPoint
Of course, connecting yout AngularJS controllers to Google Endpoints without GAPAngular was possible. But integration wasn't that easy and developpers were used to encouter always same problems.
By default, AngularJS is initialised after DOM construction, or if you prefer when ng-app is found. BTW, AngularJS can be initialised by code, when you want:
$document.onload(
function initAngular() {
angular.bootstrap($document,['myApp']);
}
);
Client.js is a library that allows to use some proxies to connect to the webservices you deployed using Google Endpoins. It mus downloaded using:
<script src="https://apis.google.com/js/client.js?onload=init"></script>
``
Once this file downloaded, the _init()_ function is called, and you can start using
this library... but, as a final step, you need to download your proxies, then you'll
be able to call your webservice.
```javascript
gapi.client.load('endpointname', 'v1',null, "http://yourserver/_ah/api").then(
function() {
// gapi.client.endpoint name is now created
// You can use your proxy
// Let's suppose your webservice exposes a listData() function...
gapi.client.endpointname.listData().execute(
function(resp) {
$scope.$apply($listData = resp.items);
}
}
);
}
);;
- You can't be sure that javascript client library (_client.js) will be downloaded when AngularJS will bootstrap... And in your opinion, what happens if you try to use a google end Point proxy in one of your AngularJS component ?
gapi.client.load(...)
undefined ... and your controller will not be able to access your end point. This is a problem...
AngularJS is based upon dependency injection, it means that if a component needs to work with another one, than you can inject on into another. thanks to GAPAngular you can now inject a Google enpoint into your components if needed !
GAPAngular is based upon Angular-deferred-bootstrap. GAPAngular is able to wait for all the Google endpoint to be completely initialized before bootstraing AngularJS.
Conf:
function init() {
var conf = {
'appName':'evalApp',
'defaultRoot':'http://endpoint-address/_ah/api',
'defaultVersion':'v1',
'endpoints': [
{'endpointname':'sessionendpoint','injectionname':'sessionproxy'}
]};
gapangular.bootstrap(conf);
}
These function must be called that way:
<script src="https://apis.google.com/js/client.js?onload=init"></script>
You may notice that GAPAngular config uses a parameter named injectionName. I think you have understood this is the name you have to use to inject this proxy into yout AngularJS components:
angular.module('evalControllers').
controller('SessionController',
[ // ...
'sessionproxy',
function ($scope,$routeParams,$location,
sessionproxy) {
// sessionproxy correspond exactement au nom dans le paramétrage donné
// un peu plus haut
}]);
Hope this help ;)
-
What about OAuth in Google End Point, need to test it...
-
May be we can talk about your ideas ?