Open puddlejumper26 opened 4 years ago
<input type='text' [(ngModel)] ='username'> <button (click)='buttonFn()'>Click</button>
username = '';
buttonFn(){ console.log(this.username) }
# Method 2 - use **`# variable`** ```html <input type='text' #input1> <button (click)='buttonFn(input1.value, $event)'>Click</button> ==> $event will pass the entire object
buttonFn(inputValue, event){ console.log(inputValue, event) }
Method 1
buttonFn(){ console.log(this.username) }