Search code examples
angulartypescript

Angular2:getting 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);
    }
   }

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


Solution

  • 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 ;)