使用PouchDB与Angular 5或6

4

我该如何将PouchDB添加到Angular 5或6项目中?我正在使用Angular 6,但找不到任何方法来实现。

1个回答

5

你可以使用这个在Angular中使用PouchDB。

import PouchDB from 'pouchdb';

这是我发现的一个涉及IT技术的示例使用Angular和PouchDB Cloudant项目。

您可以按照以下步骤使用它:

  private db: any;
  private isInstantiated: boolean;
  private listener: EventEmitter<any> = new EventEmitter();

  public constructor() {

    if (!this.isInstantiated) {
      this.db = new PouchDB('locosporalva');
      this.isInstantiated = true;
    }
  }

1
我们还需要在polyfills.ts文件中添加(window as any).global = window; - dalios
(window as any).global = window; 在启动时需要用来解决 global is not defined 错误。 - aderesh

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接