[英]Get value from emberjs form
I'm a newbie with Emberjs and I need some advices. 我是Emberjs的新手,我需要一些建议。
I try to use this addon https://github.com/indexiatech/ember-forms 我尝试使用此插件https://github.com/indexiatech/ember-forms
So I have created my form : 所以我创建了我的表格:
{{#em-form model=sessions submit_button=false}}
{{em-input property="email" type=email label="Email" placeholder="Entrer votre email..."}}
{{em-input property="password" type="password" label="Mot de passe" placeholder="Enter votre password..."}}
<div class="form-actions">
<input {{bind-attr disabled=isntValid}} type="submit" class="btn btn-primary" value="Se connecter">
</div>
{{/em-form}}
so I have a controller to catch the submit action : 所以我有一个控制器来捕获提交动作:
export default Ember.Controller.extend({
actions: {
submit: function(){
alert(this.get('sessions.email'));
}
}
});
My question is just I don't get it to how print my value from my form? 我的问题是我不明白如何从表单中打印出我的价值? I try this.get('email')
or this.get('sessions.email')
but always got an undefined
in my alert box 我尝试使用this.get('email')
或this.get('sessions.email')
但在我的警报框中始终undefined
Any help would be great! 任何帮助将是巨大的! Thanks! 谢谢!
You need to send an action from the form 您需要从表单发送操作
{{#em-form model=sessions submit_button=false action='foo'}}
...
{{/em-form}}
and then catch the action in the controller 然后在控制器中捕获动作
actions: {
foo: function() {
console.log(this.get('email'))
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.