我正在尝试进行范围输入,但是当我尝试将其传递给我的函数时,它返回undefined:
HTML:
<div class="slidecontainer">
<label>Setpoint</label>
<p>{{channel.setPoint}}</p>
<div>
<p>5</p>
<p>30</p>
</div>
<input type="range" min="5" max="30" value="50" step="0.5" class="slider"
[(ngModel)]="channel.setPoint" (onchange)= "putSetpoint(channel, this.value)">
<br>
</div>
TS文件:
putSetpoint(cb: Channel, value: number) {
console.log(value);
cb.setpoint = value;
this.homedata.setpointChannel(cb);
}
答案 0 :(得分:0)
this.value
没有引用任何内容,您必须告诉Angular您指的是input
的值:
<input #inputRange type="range" min="5" max="30" value="50" step="0.5" class="slider"
[(ngModel)]="channel.setPoint" (onchange)= "putSetpoint(channel, inputRange.value)">