Reputation: 75
How to Hide Keyboard in ionic3?
We have a problem with ionic 3 apps during testing in iPhone. After fillup Payment Gateway information (which is launched in iFrame), Whenever we go to the back page using the back button, Keyboard is not Hiding.
We used cordova-plugin-ionic-keyboard and use Keyboard.hide() method. But didn't work.
Upvotes: 3
Views: 4465
Reputation: 2624
Using Keyboard plugin for Cordova:
import { Keyboard } from '@ionic-native/keyboard/ngx';
...
constructor(private keyboard: Keyboard) { }
...
this.keyboard.show();
this.keyboard.hide();
Or if you are using Capacitor (recommended):
import { Plugins, KeyboardInfo } from '@capacitor/core';
const { Keyboard } = Plugins;
...
Keyboard.show();
Keyboard.hide();
Upvotes: 2
Reputation: 1616
Try this
import { Keyboard } from '@ionic-native/keyboard';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
constructor(public navCtrl: NavController, public keyboard : Keyboard) {
}
}
and then on back button use this
this.keyboard.close()
Upvotes: 0