html
(1、input type='search' 2、將input套在一個帶action的form中 )
<form action=""> <ion-input type="search" placeholder="請輸入搜尋關鍵字" (keypress)='test($event)'></ion-input> </form>
typescript
(監聽input的keypress事件)
test(event) { if (event && event.keyCode == 13) { alert('yes'); } }
補充:關閉input自動完成
autocomplete='off'
<form action=""> <input autocomplete='off' class="usIndexsch" type="search" name='key' placeholder="目的地/關鍵詞" [(ngModel)]='key' (keypress)='keySelect($event)'> </form>