lundi 24 octobre 2016

Changing array on template doesn't update on route/controller

I need multiple input fields to fill an array of ints.

This is my template and route:

// Route
import Ember from 'ember';

export default Ember.Route.extend({
  setupController() {
    this.controller.set('myArray', [1]);
    // ...
  }
}

// Template
<!-- ... -->

  


<p>Length: </p>
<p>First item: </p>

When the template is first rendered, the input field has value 1 and First item also shows 1, but when I change the input value to something else, First item still shows 1.

I only managed to get this to work if I replace the array of ints with an array of objects, e.g. this.controller.set('myArray', [{value: 1}] and then use the property value on the template, but I'd rather avoid this if I can. Is it possible to do this with an array of ints?




Aucun commentaire:

Enregistrer un commentaire