本文介绍了带有Google Drive Realtime API的Angular 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我希望基于 Drive Realtime API 创建一个新的应用程序,并希望使用闪亮的新 Angular 2 框架来实现.但是,我有点想找出如何最好地集成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.

使这两个框架协同工作的最佳方法是什么.特别是,我该如何使用 ngModel 调整Angular两种方式绑定之间的区别a>和Realtime API数据绑定与 gapi.drive.realtime.databinding绑定?

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?

推荐答案

您可以下载Google Drive Realtime API的声明文件(* .d.ts)此处.这为API提供了TypeScript包装器.具体来说,它定义了一个名为gapi.drive.realtime的模块,该模块的类可以在Angular2中访问.

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.

要向编译器介绍声明文件,您需要在TypeScript源文件中添加以下行:

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" />

然后,您需要导入模块的功能.一种方法是使用以下import命令:

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";

然后,您可以在Drive命名空间下访问模块的类:Drive.CollaboratorDrive.CollaborativeObject等.

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

这篇关于带有Google Drive Realtime API的Angular 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 12:25