Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Angular 2 with Google Drive Realtime API

I'm looking to create a new application based on the Drive Realtime API and want to do it with the shiny new Angular 2 framework. However, I'm kind of stuck trying to figure out how to best integrate the APIs and philosophies. I can't find any examples that use both.

What is the best way to get these two frameworks working together. In particular, how do I reconcile the differences between Angular's two way binding with ngModel and the Realtime APIs data binding with gapi.drive.realtime.databinding.Binding?

like image 468
Gary Avatar asked Feb 13 '16 01:02

Gary


People also ask

How does angular integrate with Google Drive?

First you need Google Drive API credentials, which you can set up here. From there the rest is application logic, and will depend on what exactly you are trying to do. You'll need to initialize the Client, with the API key you've created in Step 1, before you can actually interact with the API.

Is Google Drive API free?

All use of the Drive API is available at no additional cost.

Does Google Drive have an API?

The Google Drive API allows you to create apps that leverage Google Drive cloud storage. You can develop applications that integrate with Drive, and create robust functionality in your application using the Drive API.


1 Answers

You can download the declaration file (*.d.ts) for the Google Drive Realtime API here. This provides a TypeScript wrapper for the API. Specifically, it defines a module named gapi.drive.realtime whose classes can be accessed in Angular2.

To tell the compiler about the declaration file, you need to add the following line to your TypeScript source file:

///<reference path="google-drive-realtime-api.d.ts" />

Then you need to import the module's features. One way to do this is with the following import command:

import * as Drive from "gapi.drive.realtime";

Then you can access the module's classes under the Drive namespace: Drive.Collaborator, Drive.CollaborativeObject, and so on.

like image 170
MatthewScarpino Avatar answered Oct 15 '22 14:10

MatthewScarpino