Keyboard event with ionic form

2019-04-11 21:26发布

I have an input field in my ionic form:

<input type="search" placeholder="Search" ng-model="searchKey">
<button class="button button-clear" ng-click="search()">Search</button>

And I wanna add an event that calls the function "search()" when I press enter button of my keyboard.

Is there any suggestion ?

Thank you in advance

1条回答
Emotional °昔
2楼-- · 2019-04-11 21:54

You can use this directive ng-enter, like this

<input type="search" placeholder="Search" ng-enter="search()" ng-model="searchKey">
查看更多
登录 后发表回答