如何在 Angular 中启用 PouchDB Debug

How to enable PouchDB Debug in Angular

本文关键字:启用 PouchDB Debug Angular      更新时间:2023-09-26

我正在开发一个原型Web应用程序。我使用Yeoman创建了一个带有Grunt,NPM和Bower等的Angular应用程序。PouchDB API 说你可以像这样启用调试:

PouchDB.debug.enable('*');

但是,这需要安装节点调试模块。我尝试通过 bower 安装它并在我的索引中引用它.html但无济于事。如何将调试模块注入 Angular 中?还是此功能仅在 PouchDB 从 Node.js 服务器运行时可用?

编辑:

我得到的确切错误是下面。它抱怨的台词是:PouchDB.debug.enable('*');

TypeError: Cannot read property 'enable' of undefined
    at new <anonymous> (http://localhost:9000/scripts/services/taskdb.js:13:15)
    at invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4140:23)
    at Object.<anonymous> (http://localhost:9000/bower_components/angular/angular.js:3998:24)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.enforcedReturnValue [as $get] (http://localhost:9000/bower_components/angular/angular.js:3982:37)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at http://localhost:9000/bower_components/angular/angular.js:3947:37
    at getService (http://localhost:9000/bower_components/angular/angular.js:4088:39)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4120:13)
angular.js:11413 TypeError: Cannot read property 'enable' of undefined
    at new <anonymous> (http://localhost:9000/scripts/services/taskdb.js:13:15)
    at invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.instantiate (http://localhost:9000/bower_components/angular/angular.js:4140:23)
    at Object.<anonymous> (http://localhost:9000/bower_components/angular/angular.js:3998:24)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at Object.enforcedReturnValue [as $get] (http://localhost:9000/bower_components/angular/angular.js:3982:37)
    at Object.invoke (http://localhost:9000/bower_components/angular/angular.js:4129:17)
    at http://localhost:9000/bower_components/angular/angular.js:3947:37
    at getService (http://localhost:9000/bower_components/angular/angular.js:4088:39)
    at invoke (http://localhost:9000/bower_components/angular/angular.js:4120:13) <div ng-view="" class="ng-scope">

当您使用 PouchDB 时,调试模块已经安装。除了呼叫PouchDB.debug.enable('*')之外,您无需执行任何操作。:)

请注意,在 PouchDB v7.0.0 中,需要加载一个单独的插件。