angular viewchild input element value 1

angular viewchild input element value

// in html

// in .ts
@ViewChild('input') input:ElementRef; 
//Output value
console.log(this.input.nativeElement.value);

Here is what the above code is Doing:
1. We are using the @ViewChild decorator to get a reference to the input element.
2. We are using the ElementRef to get the native element.
3. We are using the nativeElement property to get the value of the input element.

Similar Posts