简体   繁体   中英

How to enable PouchDB Debug in Angular

I am developing a prototype web application. I used Yeoman to create an Angular application with Grunt, NPM, and Bower etc. The PouchDB API says you can enable debugging like so:

PouchDB.debug.enable('*');

This however requires the node debug module to be installed. I have tried installing it via bower and referencing it in my index.html but to no avail. How do I inject the debug module into Angular? Or is this function only available when the PouchDB is ran from a Node.js server?

EDIT:

The exact error I am getting is bellow. The line it complains about is: 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">

When you use PouchDB, the debug module is already installed. You don't need to do anything except call PouchDB.debug.enable('*') . :)

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM