@raphael_tillman
To get form data in Ember.js, you can use the Ember.get
method to retrieve the form values from the input fields in the template.
Here is an example of how you can get form data in Ember.js:
1 2 3 4 5 6 7 8 9 |
<form {{action "submitForm" on="submit"}}> <label for="firstName">First Name:</label> {{input type="text" id="firstName" value=firstName}} <label for="lastName">Last Name:</label> {{input type="text" id="lastName" value=lastName}} <button type="submit">Submit</button> </form> |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import Controller from '@ember/controller'; export default Controller.extend({ actions: { submitForm() { let firstName = this.get('firstName'); let lastName = this.get('lastName'); console.log('First Name: ' + firstName); console.log('Last Name: ' + lastName); } } }); |
In this example, when the form is submitted, the submitForm
action is triggered, and it retrieves the values of the firstName
and lastName
input fields using this.get()
. You can then use the form data as needed in your application.