I'm following a tutorial on building an ember 2.10 app. I've moved my validation logic out of my contact controller and placed it inside my contact model. I've placed my action (saveContact) in my contact routes file. I can save my new contact to Firebase database without error. I'm stuck on how to clear out my form.
My contact route file looks like
import Ember from 'ember';
export default Ember.Route.extend({
model() {
return this.store.createRecord('contact');
},
actions: {
saveContact(newContact) {
newContact.save().then((response) => {
const email = this.get('model.email');
const message = this.get('model.message')
this.set('email', '');
this.set('message', '');
})
}
}
});
I'm trying to retrieve the current value in the form and set both message and email to empty strings.
I've run a test and console logged email to the console and it return undefined.
In the input fields, the value being passed in are model.email and model.message.
Has anyone else been stuck on this problem?
Aucun commentaire:
Enregistrer un commentaire