2016-07-27 81 views
1

app.js遺漏的類型錯誤:無法讀取的不確定

service.js

財產 'currentUser' 當我在控制檯本地主機上運行我有錯誤

bundle.js:7541 Uncaught TypeError: Cannot read property 'currentUser' of undefined(anonymous function) @ bundle.js:7541invoke @ bundle.js:12268(anonymous function) @ bundle.js:12076forEach @ bundle.js:7880createInjector @ bundle.js:12076doBootstrap @ bundle.js:9310bootstrap @ bundle.js:9331angularInit @ bundle.js:9216(anonymous function) @ bundle.js:39027j @ jquery.js:3047fireWith @ jquery.js:3159ready @ jquery.js:3365I @ jquery.js:3380

請幫助(我想我忘了什麼事)

+0

這是相當果然錯誤。 Angular中的服務是懶惰的實例化組件。我沒有注意到你在哪裏使用'AuthenticationService' –

回答

0

在app.js裏面有$ window.localStorage.currentUser。

$ window.localStorage未定義,所以你得到的錯誤找不到currentUser的undefined。

變化:如果($ window.localStorage & & $ window.localStorage.currentUser)

相關問題