我不斷收到的
Error: undefined is not an object (evaluating '$rootScope.user.userMessage')
錯誤與此代碼:
if (typeof($rootScope.user.userMessage) === null) {
,但如果我有在$ rootScope東西。 user.userMessage它不會崩潰。我如何執行檢查,看看這是未定義還是爲空,以便事件不會中斷?
其他的事情我已經嘗試過包括:
if (typeof($rootScope.user.userMessage) === undefined) {
if ($rootScope.user.userMessage === undefined) {
檢查$ rootScope.user是否爲空。 –