I'm trying out Octane, and for some reason, if I show an array in a template and I add a new object to it, the UI doesn't update. What am I doing wrong?
Here is my template:
<label for="new-field-name">Field Name</label>
<Input id="new-field-name" @value= type="text" />
<button >Add field</button>
<p></p>
And the component:
import Component from '@glimmer/component';
import { tracked } from '@glimmer/tracking';
import { action } from '@ember/object';
export default class ConfigControlsComponent extends Component {
@tracked fields = []
@tracked newFieldName = ''
@action addField() {
this.fields.push({
name: this.newFieldName
})
console.log(this.fields)
}
}
The console.log
shows the array with the new object added to it, and the fields
array is tracked, but nothing changes when I click the button.
Aucun commentaire:
Enregistrer un commentaire