javascript - Error with PouchDB: TypeError: angular.factory is not a function -
i'm trying figure out how use pouchdb in angularjs. i'm trying follow these instructions https://github.com/wspringer/angular-pouchdb
i think i'm having problem understanding syntax creating factories and/or services. far section on "interacting database"
app.js
'use strict'; angular .module('myappapp', [ 'ngcookies', 'ngresource', 'ngsanitize', 'ngroute', 'pouchdb' ]) .config(function ($routeprovider) { $routeprovider .when('/', { templateurl: 'views/main.html', controller: 'mainctrl' }) .otherwise({ redirectto: '/' }); }) angular.factory('someservice', function(pouchdb) { // pouchdb. var db = pouchdb.create('testdb'); pouchdb.destroy('testdb'); db.put({_id: 'foo', name: 'bar'}); });
when add "db.put", message see in browser's console is:
[15:17:45.343] typeerror: angular.factory not function @ http://127.0.0.1:9000/scripts/app.js:21
the angular
object not have factory method, returned undefined.
try putting on object returned module method.
angular .module('myappapp', [ 'ngcookies', 'ngresource', 'ngsanitize', 'ngroute', 'pouchdb' ]) .config(function ($routeprovider) { $routeprovider .when('/', { templateurl: 'views/main.html', controller: 'mainctrl' }) .otherwise({ redirectto: '/' }); }) // note difference here, using object returned module() , config() .factory('someservice', function(pouchdb) { // pouchdb. var db = pouchdb.create('testdb'); pouchdb.destroy('testdb'); db.put({_id: 'foo', name: 'bar'}); });
Comments
Post a Comment