AngularJS和谷歌云终端:穿行需要 [英] AngularJS and google cloud endpoint: walk through needed

查看:104
本文介绍了AngularJS和谷歌云终端:穿行需要的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来AngularJS但我真的很喜欢的方式工作AngularJS所以我想部署它作为客户端我的谷歌云终端后端。然后,我立即得到了两个问题:

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 problems:

1,如果把在 myCallBack函数,所以它能够工作到ANgularJs控制器?

1, Where to put the myCallback, so it's able to work into the ANgularJs controller?

<script src="https://apis.google.com/js/client.js?onload=myCallback"></script>

2,我如何能够做的oauth2?以及如何在用户授权控制器知道?

2, How I'm able to do the oauth2? and how the controller knows if the user authorized?

gapi.auth.authorize({client_id: myCLIENT_ID,
      scope: mySCOPES,.....

任何帮助是AP preciated。

Any help is appreciated.

推荐答案

有关加载谷歌JavaScript库AngularJs,传递到谷歌JavaScript库的onLoad回调函数是引导AngularJS,像这样的功能:

For loading Google Javascript Library with AngularJs, the callback function passed to onLoad of Google Javascript Library is the function that bootstrap AngularJS, like this:

这正好HTML文件的最后:

This goes to the final of html file:

<script src="https://apis.google.com/js/client.js?onload=startApp">

然后,在&LT; HEAD&GT; 部分,你引导的角度是这样的:

Then, in <head> section you bootstrap angular like this:

<script type='text/javascript'>

function startApp() {

    var ROOT = 'http://<yourapi>.appspot.com/_ah/api';
    gapi.client.load('myapifromgoogleendpoint', 'version1', function() {
        angular.bootstrap(document, ["myModule"]);
    }, ROOT);
}

</script>

正如贤治描述的,你还需要从你的HTML删除NG-应用指令。

这篇关于AngularJS和谷歌云终端:穿行需要的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆