1
私は、詳細ビューのメインリストを持っている簡単なアプリケーションを作成しようとしていますが、私はこのエラーを乗り越えることはできません。
ionic.bundle.js:26794 TypeError: $q.when is not a function
at Object.getAllObjects (app.services.js:13)
at app.controller.js:11
at ionic.bundle.js:56230
at Object.ready (ionic.bundle.js:2140)
at Object.ready (ionic.bundle.js:56223)
at new MainController (app.controller.js:7)
at Object.instantiate (ionic.bundle.js:18010)
at $controller (ionic.bundle.js:23412)
at self.appendViewElement (ionic.bundle.js:59900)
at Object.render (ionic.bundle.js:57893)
それが参照しているコードは次のとおりです。
app.factory('DatabaseService', ['$q', '$http','$rootScope',
function DatabaseService($rootScope, $q, $http) {
var _db;
var _content;
return {
initDB: initDB,
getAllObjects: function getAllObjects() {
if (!_content) {
return $q.when(_db.allDocs({ include_docs: true}))
.then(function(docs) {
_content= docs.rows.map(function(row) {
return row.doc;
});
_db.changes({ live: true, since: 'now', include_docs: true})
.on('change', onDatabaseChange);
return _content;
});
} else {
return $q.when(_content);
}
},
getObject: function getObject(id){
var index = findIndex(($rootScope._content),id);
return $rootScope._content[index];
}
};
すべての依存関係が正しいと思われるので、なぜこの奇妙なエラーが発生するのですか?私の最近のエラーの大半は「機能ではない」エラーであると思われますが、なぜその理由が分かりません。あなたの注入を混合
ありがとうございました!このような簡単な修正 –