angularjs - 带有 AngularJS 的 Google 登录按钮

标签 angularjs google-api

我正在尝试使用 AngularJS 创建一个 Google 连接按钮。

我正在关注这个:https://developers.google.com/identity/sign-in/web/sign-in

我在 index.html 中加载了 platform.js,但该文件包含一个显示另一个 HTML 模板的 ng-view。

那么

<div class="g-signin2" data-onsuccess="onSignIn"></div>


没有加载..

访问数据成功的任何解决方案?

最佳答案

试试这个插件

https://github.com/sirkitree/angular-directive.g-signin

用法

  • 包括 google-plus-signin.js。
  • 将directive.g+signin 添加为您的应用程序的依赖项。
  • 添加到您的应用程序。
  • 在您的 $scope 上为 event:google-plus-signin-success 创建一个监听器,以检测您的用户何时通过身份验证。
  • 可选:监听 event:google-plus-signin-failure 以处理身份验证错误和注销。

  • 例子
    <div ng-app="directive.g+signin">
      <google-plus-signin clientid="620125449078"></google-plus-signin>
      <p>^ This is a Google Plus sign-in button</p>
    </div>
    
      $scope.$on('event:google-plus-signin-success', function (event,authResult) {
        // Send login to server or save into cookie
      });
      $scope.$on('event:google-plus-signin-failure', function (event,authResult) {
        // Auth failure or signout detected
      });
    

    关于angularjs - 带有 AngularJS 的 Google 登录按钮,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43409846/

    相关文章:

    android - Google hangouts v2.3 增加语音通话功能

    api - 在 oAuth Google Api Flow 中使用 "create_delegated"时遇到问题....gDrive

    php - 如何使用 Google API 在团队云端硬盘中创建文件夹?

    javascript - Uncaught Error : [$injector:modulerr] Failed to instantiate module myApp due to: Error: [$injector:modulerr]

    javascript - 从 Angular 到 Node 的 POST 数据不起作用

    javascript - 如何使用 Angular 设置背景颜色?

    angularjs - AngularJS将多个参数传递给指令ng-repeat

    c# - 如何配置对 YouTube 凭据进行身份验证的网站以供控制台应用程序使用?

    android - Google Api 返回 "The API (Blogger API) is not enabled for your project.",即使我在控制台中启用了 Blogger API

    javascript - Kendo ui 下拉列表删除特定项目