I want to get value from <input> tag and pass it as parameter to action in EmberJS
When I used JQuery {{action 'add' this.$('#x').val()}} Ember failed to build giving parse error on line ...
Here I want to pass x and y as parameter to the {{action}}, I know the syntax for sending parameters is {{action parameter1 parameter2 ..etc}}
templates\alpha.hbs
<h1>alpha template</h1>
<div>
<label>X value</label>
<input type="text" id="x">
<label>Y</label>
<input type="text" id="y">
<input type="button" id ="add-button" value="Add" {{action 'add' }}>
</div>
controllers\alpha.js
import Ember from 'ember';
export default Ember.Controller.extend({
actions:{
add: function(x, y){
alert('this is done right '+x+ ' ' + y);
}
}
});
I tested the code without passing parameters and the code worked as expected giving the alert required
Aucun commentaire:
Enregistrer un commentaire