私のangular2-seedプロジェクト(入力とWebpackを使用)にlocalForageを追加する際に問題があります。私は入力とangle2に新しいです。タイピングコマンドでangular2/typescriptプロジェクトの未定義変数localforage
は、私はインポートを解決することができ、私のIDEファイル私のservice.ts
で
const localforage:LocalForage = require("localforage");
を追加私のファイルでtypings.json
"localforage": "registry:dt/localforage#0.0.0+20160316155526",
に活字体の定義を追加し、自動ありません完全
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)
任意の提案?おかげです!
で
export
キーワードを追加するのを忘れて、あなたのangular2アプリは、私が現在ローダーとして 'webpack'を使用 –