TheUnreal
TheUnreal

Reputation: 24492

Changing Input value from component

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.

Upvotes: 3

Views: 5617

Answers (1)

JukkaL
JukkaL

Reputation: 161

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';

Upvotes: 5

Related Questions