我有以下輸入,我想在按下回車后觸發事件:
<input
matInput
type="number"
min="0"
placeholder="0"
(keyup.enter)="minValue($event)"
/>
我也試過 (keydown.enter)="minValue($event)" 沒有成功。用戶如何鍵入一個值以及在按下回車鍵時呼叫 minValue 方法?
此外,當我單擊輸入欄位以輸入值時,輸入框會在寫入任何內容之前消失。
非常感謝。
uj5u.com熱心網友回復:
試試這樣:
.html
<input
matInput
type="number"
min="0"
placeholder="0"
[(ngModel)]="myValue"
(keyup.enter)="minValue(myValue)"
/>
.ts
minValue(evt){
console.log(evt)
}
演示
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/495092.html
上一篇:型別“節點”缺少以下屬性
