Angular2:获取event.target.value [英] Angular2:getting event.target.value

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

问题描述

我想通过以下代码获取 event.target.value .

I want to get event.target.value by the codes below.

    <input 
      mdInput 
      #owner
      required 
      placeholder="荷主" 
      [formControl]="detail.ownerTx" 
      [mdAutocomplete]="autoTxt" 
      (change)="detail.changeOwner(owner.value)"
     >

   class Detail {
    changeOwner(val: string){
     console.log(val);
    }
   }

但是 console.log(val)的答案什么都没有....真正进行数据绑定的任何想法?

but the answer of the console.log(val) is nothing.... any idea to actually do the data-binding??

推荐答案

我想,如果您想使用(keyup)="changeInput($ event)"来获取此值,则应该使用(keyup)或其他键盘事件处理程序您可以访问DOM事件和值;)

I think you should use (keyup) or another keyboard event handler if you want to get this value using (keyup)="changeInput($event)" then you can access you DOM event and value ;)

这篇关于Angular2:获取event.target.value的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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