Git Product home page Git Product logo

angular-gapi's Introduction

Angular-GAPI

Angular-GAPI is an AngularJS module for accessing different Google APIs.

The code is based on ngGAPI

Load

To use the module, include the main Angular-GAPI javascript file in your web page, as well as the scripts for all the API's that will be used:

<!DOCTYPE HTML>
<html>
<body ng-app="app">
  //.....
  <script src="bower_components/angular-GAPI/lib/angular-GAPI.js"></script> 
  <script src="bower_components/angular-GAPI/lib/plugin/gapi.calendar.factory.js"></script> 
  <script src="bower_components/angular-GAPI/lib/plugin/gapi.user.factory.js"></script>
</body>
</html>

ngGAPI requires Google API JavaScript client library

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

Installation

Bower

$ bower install quivr/angular-GAPI --save

Npm

$ npm install quivr/angular-GAPI --save

then load it in your html

Add module dependency

angular.module('myApp', [
  'angularGAPI'
]);

Usage

After you register your app in the Google APIs Console, configure angular-GAPI with credentials and whatever scopes you need for your app.

angular.module('myApp')
  .value('GoogleApp', {
    apiKey: 'YOUR_API_KEY',
    clientId: 'YOUR_CLIENT_ID',
    scopes: [
      // whatever scopes you need for your app, for example:
      'https://www.googleapis.com/auth/drive',
      'https://www.googleapis.com/auth/youtube',
      'https://www.googleapis.com/auth/userinfo.profile'
      // ...
    ]
  })

To use a specific service, inject it into your controllers by name. All GAPI methods return a promise.

angular.module('myApp')
  .controller('VideosCtrl', function ($scope, Youtube) {
    $scope.videos = Youtube.search({ part: 'snippet', q: 'Search terms' })
  });

Services

GAPI authorization

  • GAPI.init()
  • GAPI.disconnect()

Note: If pop-ups are being blocked, make sure to have gapi loaded before calling GAPI.init().

gapi.load('auth', function() { GAPI.init() });

For a full documentation of the available functions, consult the wiki

angular-gapi's People

Contributors

berndschrooten avatar entropitor avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

angular-gapi's Issues

Unknown provider: DriveProvider <- Drive

Unknown provider: DriveProvider <- Drive <- VideoController

Following the boilerplate installation, got this output:

angular.js:14110 Error: [$injector:unpr] Unknown provider: DriveProvider <- Drive <- VideoController
http://errors.angularjs.org/1.5.9/$injector/unpr?p0=DriveProvider%20%3C-%20Drive%20%3C-%20VideoController
at angular.js:68
at angular.js:4554
at Object.getService [as get] (angular.js:4707)
at angular.js:4559
at getService (angular.js:4707)
at injectionArgs (angular.js:4732)
at Object.invoke (angular.js:4754)
at $controllerInit (angular.js:10518)
at nodeLinkFn (angular.js:9416)
at compositeLinkFn (angular.js:8757)

app.js

var app = angular.module('MyApp',['MyApp.services']);
angular.module('app', [
'angularGAPI'
]);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.