Angular 4 - 获取输入值 [英] Angular 4 - get input value

查看:23
本文介绍了Angular 4 - 获取输入值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何从角度 4 的输入中获取值.我查看了有关 angular 的文档,并且带有关键事件的示例对我来说效果不佳,我找不到合适的示例如何执行此操作,因此请帮助我

I would like to know how to get the value from an input on angular 4. I looked over the documentation on angular and the example with the key event doesn't work very well for me and I can't find a proper example how to do this so please help me out

问题:我尝试读取输入的值,然后将值提交给另一个组件,该组件会将值添加到选择标签(例如,将人名发送到选择标签的列表)

The problem: I try to read the input's value and after submiting the value to another component that will add the value to a select tag(e.g. send the name of the person to a list for a select tag)

推荐答案

<form (submit)="onSubmit()">
   <input [(ngModel)]="playerName">
</form>

let playerName: string;
onSubmit() {
  return this.playerName;
}

这篇关于Angular 4 - 获取输入值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆