loading and error substates은 경로를로드 할 때만 사용됩니다. 컨트롤러 액션 중에 액션을 호출 할 방법이 없습니다 (액션이 새로운 경로를로드하지 않는 한, 그 상태는 여전히 액션이 아니라 새로운 경로를로드하는 것과 관련됩니다). 특성 및 일부를 사용하여 동작을 수행 할 때
여전히 로딩 템플릿을 표시 할 수
템플릿 :
<!-- templates/components/user-account.hbs -->
{{#if busy}}
{{partial 'loading-template-name'}}
{{else}}
{{!-- template content --}}
<button {{action "save"}}>Save</button>
{{/if}}
성분 :
// components/user-account.js
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
save: function() {
if (this.get('busy')) {
return;
}
this.get('user').save()
.then(() => {
// handle success
})
.catch((e) => {
// handle error
})
.finally(() => {
this.set('busy', false);
});
},
},
})
로딩 부 상태 것 'beforeModel,'model' 또는'afterModel'이 약속을 되 돌렸을 때만 보여줄 것입니다. 모델 저장 중에 무언가를 보여주고 싶다면 커스텀 로더를 보여줘야합니다 –