I am trying to create a simple Ember application that collects information from a form. I use this tutorial as a guide. In the tutorial, it has the following code for capturing 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 some relevant form code:
<div class="form-group"> <label for="image">Image URL</label> {{input value=image id="image"}} </div> <button {{action 'saveRental1'}}>Save</button> </form>
In my decision, I could not get this to work. this.get ('whatever') always displayed as "undefined" in my code. After a little debugging, I was able to find a solution, but that 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?
source share