我在将angularFind添加到我的angular2-seed项目(使用类型和webpack)时遇到问题。我对typings和angular2很陌生。在angular2/typescript项目中未定义的变量localforage
随着分型的命令,我添加了打字稿定义来typings.json
"localforage": "registry:dt/localforage#0.0.0+20160316155526",
在我文件我加
const localforage:LocalForage = require("localforage");
在我service.ts
文件我的IDE能够解决的进口和自动做完成
import {localforage} from "localforage";
this.store = localforage.createInstance({
name: "products"
})
bu T当我运行应用程序,进口localforage是undefined
ORIGINAL EXCEPTION: TypeError: Cannot read property 'createInstance' of undefined
ORIGINAL STACKTRACE:
TypeError: Cannot read property 'createInstance' of undefined
at new SearchService (eval at <anonymous> (http://localhost:3000/app.bundle.js:36:2), <anonymous>:20:53)
at eval (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:189:2), <anonymous>:13:47)
at Injector._instantiate (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:777:27)
at Injector._instantiateProvider (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:715:25)
at Injector._new (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:704:21)
at InjectorInlineStrategy.getObjByKeyId (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:247:33)
at Injector._getByKeyDefault (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:921:37)
at Injector._getByKey (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:867:25)
at Injector._getByDependency (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:853:25)
at Injector._instantiate (eval at <anonymous> (http://localhost:3000/vendor.bundle.js:141:2), <anonymous>:743:36)
任何建议?谢谢!
看来你angular2应用简化版,找出你的service..ts'localforage'文件 –