jeudi 8 octobre 2015

EmberJS Sending a property to another controller

I'm trying to pass back a property to use in a view on another route. For exmaple, my contact/user/new controller is doing the following:

var newContact = this.get('store').createRecord('contact', contactData);
  newContact.save().then((contact) => {
    this.transitionToRoute('contacts');
    this.set('successMessage', 'You have successfully created a new contact!');
  })
  .catch((response) => {
    response.errors.forEach((error) => {
      this.set('errorMessages', error.message);
    });
  });

Everything works for me except that successMessage line.

this.set('successMessage', 'You have successfully created a new contact!');

I'd like to have it accessible on the customers template so I could do something like:

{{#if successMessage}}
  <div class="success-message">
    {{successMessage}}
  </div>
{{/if}}

If anyone has any ideas, that would be great.




Aucun commentaire:

Enregistrer un commentaire