Hi,
I’m trying to close a keyboard when user clear the search bar. This is what I’ve done so far
<ion-col style="padding:0px;" col-90 center>
<ion-searchbar style="padding:0px;" (ionInput)="getItems($event)" (ionClear)="onClear($event)"></ion-searchbar>
</ion-col>
onClear(event){
console.log('g');
Keyboard.close();
}
I’ve used ionic-native for keyboard API. As far as i think, it is supposed to close the keyboard as soon as i click cross button on search bar. The problem is it doesn’t do that! Am I missing something?
MattE
December 29, 2016, 9:04am
2
Do you see the “g” output in the console?
Yes I see it, the function runs fine but Keyboard.close() doesn’t close the keyboard
MattE
December 29, 2016, 10:50am
4
Can you try this code?
cordova.plugins.Keyboard.close();
Yes I tried that, I get error while building
[19:05:57] Error: Error at
/Users/abdulwahab/Documents/mobileapps/bytemunch/.tmp/pages/choose-location/choose-location.ts:126:5
[19:05:57] Cannot find name 'cordova'.
[19:05:57] ngc failed
[19:05:57] ionic-app-script task: "build"
[19:05:57] Error: Error
declare var cordova; // after import’s