0
私はnew-thing
のルートを持っており、そのテンプレートはフォームです。このフォームが送信されると、私はアクションを呼び出して、this
を渡します。私のテンプレートでEmberでの保存に失敗した場合のエラーの表示
export default Ember.Route.extend({
model() {
return {};
},
actions: {
createThing(thing) {
let thingToSave = this.store.createRecord('thing', {
name: thing.name,
description: thing.description
});
thingToSave.save().then(function() {
// happy path
}).catch(function(reason) {
// unhappy path
});
}
}
});
、私は次のようにあります
{{#each model.errors.name as |error|}}
<div class="error">
{{error.message}}
</div>
{{/each}}
しかし、何かがかなり右に配線されていません。私は経路のモデルがどのように終わっているのかはっきりしていないthing
bad path
がトリガーしたときにエラーがレンダリングされるように保存しようとしています。
Haが、私はちょうどこれを思い付くていました。私が別にやっているのは 'this.get( 'model')'の代わりに 'let this = this.modelFor(this.routeName);'だけです。ありがとう〜 – Gregg
あなたは大歓迎です。私のための素晴らしいリファレンスは、101年前のことです:https://leanpub.com/ember-cli-101私はこの質問への回答をかなり早く検索するためにそれを使用しました。 –