Ember js 表单保留旧值

Ember js form retains old values

我在 SO 上尝试了其他答案,但 none 有帮助。

app/routes/card/new.js

actions: {
  save(title, description) {
    const newCard = this.get('store').createRecord('card', { title, description } );
    newCard.save().then((card) => {
      this.transitionTo('card.card', card);
    });
  }
}

对于视图,我:

app/templates/card/new.hbs

<form>
  <fieldset class="form-group">
    <label for="card-title">Card Title</label>
    {{input type="text" value=title class="form-control" id="card-title" placeholder="Enter the title of the card"}}
    <small class="text-muted">Give your card a nice title</small>
  </fieldset>

  <fieldset class="form-group">
    <label for="card-description">Card Description</label>
    {{textarea value=description class="form-control" id="card-description" rows="3"}}
    <small class="text-muted">Describe your card</small>
  </fieldset>

  <div class="btn-group" role="group" aria-label="Save or Cancel your card">
    <button {{action 'save' title description}} class="btn btn-secondary">Save</button>
    <button {{action 'cancel'}} class="btn btn-danger">Cancel</button>
  </div>
</form>

当我创建一张卡片时,它工作正常,但当我再次尝试创建一辆新车时,表格保留了旧值,这些值在刷​​新时消失。

app/routes/card/new.js

model(){
  return this.get('store').createRecord('card');
}

app/controllers/card/new.js

actions: {
  save(){
   this.get('model').save().then((card) => {
      this.transitionTo('card.card', card);
    });
}
}

app/templates/card/new.hbs

<form>
  <fieldset class="form-group">
    <label for="card-title">Card Title</label>
    {{input type="text" value=model.title class="form-control" id="card-title" placeholder="Enter the title of the card"}}
    <small class="text-muted">Give your card a nice title</small>
  </fieldset>

  <fieldset class="form-group">
    <label for="card-description">Card Description</label>
    {{textarea value=model.description class="form-control" id="card-description" rows="3"}}
    <small class="text-muted">Describe your card</small>
  </fieldset>

  <div class="btn-group" role="group" aria-label="Save or Cancel your card">
    <button {{action 'save'}} class="btn btn-secondary">Save</button>
    <button {{action 'cancel'}} class="btn btn-danger">Cancel</button>
  </div>
</form>