我正在用用戶註冊構建一個ember.js web應用程序。如果註冊失敗(例如無效的電子郵件),則API返回錯誤。問題是這會使模型進入錯誤狀態,如果用戶試圖再次嘗試註冊,Ember.js會提出錯誤Uncaught Error: Attempted to handle event 'willSetProperty' on <App.User:ember451:null> while in state rootState.error.
,然後似乎變得沒有響應。在Ember.js中,模型如何從請求錯誤中恢復?
是否必須手動重置錯誤後的狀態?
becameInvalid: function() {
// reset the state after an error
var parentState = this.get('stateManager').get('currentState').parentState.dirtyType;
if (parentState === "updated") {
this.get('stateManager').transitionTo('loaded.updated');
} else {
this.get('stateManager').transitionTo('loaded.created.uncommitted');
}
}
這似乎有點奇怪。我是否設置錯誤?有沒有其他方法,或者我應該在錯誤後重置?