我已经采用了数字类型的离子输入值,我想访问我的ngAfterViewInit下的值,我得到未定义的值,请让我知道正确的解决方案?
以下是代码:
<ion-input id="qty" type="number" placeholder="Enter Stop Index" (ngModel)="stop"></ion-input>
代码:
ngAfterViewInit() {
var slidetostop= (<HTMLInputElement>document.getElementById('qty')).value;
}
答案 0 :(得分:1)
你可以用javascript实现它。看看下面的代码。
var slidetostop ="8" //you can put any static number.
document.getElementById("qty").addEventListener("keyup", function () {
slidetostop = parseInt((<HTMLInputElement>document.getElementById("qty")).value);
}, false);