Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing Input value from component

Tags:

angular

Assumign I have the following template expression:

<md-input type="number" #power [placeholder]="powerLabel" required>
</md-input>

I want to access power.value from my component .ts file, how I can do that?

Using ([ngModel]) gave me some console errors I couldn't manage to handle.

like image 781
TheUnreal Avatar asked Dec 05 '25 06:12

TheUnreal


1 Answers

Not sure if it will work but have you tried creating a member variable using ViewChild like this: @ViewChild('power') power; Then you can handle the value using this.power.nativeElement.value Remember to import ViewChild: import {ViewChild} from '@angular/core';

like image 156
JukkaL Avatar answered Dec 07 '25 21:12

JukkaL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!