I'm attempting to build a simple Ember application that collects information from a form. I'm using this tutorial as a guide. In the tutorial it has the following code to grab information from a form:
export default Ember.Component.extend({
...
actions: {
saveRental1() {
var params = {
owner: this.get('owner'),
city: this.get('city'),
type: this.get('type'),
image: this.get('image'),
bedrooms: this.get('bedrooms'),
};
...
this.sendAction('saveRental2', params);
}
}
});
here is a bit of the relevant form code:
<div class="form-group">
<label for="image">Image URL</label>
</div>
<button >Save</button>
</form>
In my solution I could not get this to work. this.get('') always showed up as 'undefined' in my code. After a bit of debugging I was able to find a solution, but it meant changing my code from this.get('city')
to this.controller.get('city')
Can someone explain what I'm doing wrong or why? Is it 'standard' to use this.controller?
Aucun commentaire:
Enregistrer un commentaire