Reputation: 1621
Here is my code:
angular.module('app', ['ionic', 'ngMessages', 'ngCordova', 'jett.ionic.filter.bar',
'ion-datetime-picker', 'angularMoment', 'ngCordova.plugins.progressIndicator', 'ionic-timepicker']) //, $httpProvider
.config(configBlock)
// .factory('MyHttpInterceptor', MyHttpInterceptor)
.run(function ($ionicPlatform) {
$ionicPlatform.ready(function () {
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
StatusBar.styleDefault();
}
});
});
But I got
"Cannot read property 'Keyboard' of undefined" error
once I run the command ionic serve
. I have already added the plugin --> ionic-plugin-keyboard to my project. Can someone help me to find this issue?
Upvotes: 0
Views: 3053
Reputation: 11
Fix Only for Android :
Use window.Keyboard instead of cordova.plugins.Keyboard
Your code should like this :
if (window.cordova && window.Keyboard) {
window.Keyboard.hideKeyboardAccessoryBar(true);
}
In the doc, it's written that there is a method called Keyboard.hideFormAccessoryBar. It's true for iOS but on Android, the method is called Keyboard.hideKeyboardAccessoryBar. You can check the js code in Keyboard.js file located under : file:///android_asset/www/plugins/cordova-plugin-ionic-keyboard/www/android/keyboard.js. Or you can use chrome://inspect/#devices to debug whats going on.
I hope this will fix your issue.
Upvotes: 1