【发布时间】:2014-08-28 14:11:33
【问题描述】:
我正在使用 Meanjs 和 ydn-db 来支持 indexeddb 的项目。
所以我正在尝试以角度提供服务,但我无法找到正确包含 js 文件的方法。我尝试通过以下方法安装库:
- 凉亭安装 ydn-db
-
凉亭安装ydndb
第一种情况,我找不到像
ydn.db-isw-core-qry-dev.js这样的合适的.js 文件。现在第二个将安装我可以工作的两个缩小版本,但我总是得到 ydn not found 错误
现在通过查看开发者页面http://dev.yathit.com/ydn-db/getting-started.html,我可以看到他有一种方法可以在 AMD 加载器部分中生成 require,我根本不知道如何在服务工厂中使用它。
这是我在工厂内尝试做的事情,顺便说一句,我认为这不是最佳实践......
这些是我尝试加载时遇到的错误...
我怎样才能使用这个库,同时仍然遵循 Angular 的最佳实践,或者至少只是让它正常工作?
ldb undefined
Object {db: Object, debug: Object}
Uncaught ydn.error.ArgumentException: Unknown attribute "keypath"
angular.module(ApplicationConfiguration.applicationModuleName).factory('Localdb',['$resource','$q',
function($resource,$q) {
var deferred=$q.defer();
require.config({
baseUrl: '/content',
paths: {
ydn: 'scripts/ydn.db-isw-core-qry-dev'
}
});
require(['scripts/ydn.db-isw-core-qry-dev'], function(ldb){
console.log ('ldb',ldb);//this is undefined
var schema ={
stores:[
{
name:'process',
keypath:'_id',
indexes:[{
name:'processId',
keypath:'processId',
unique:false
},{
name:'processMeta',
keypath:'processMeta',
unique:false
}
]
}
]
};
console.log(ydn);//this gets back ok but then the keypath error???
deferred.resolve(new ydn.db.Storage('pdc',schema));
});
return deferred.promise;
}
]);
【问题讨论】:
标签: angularjs requirejs ydn-db meanjs