ionic-team / ionic-plugin-keyboard

Ionic Keyboard Plugin for Cordova
Apache License 2.0
610 stars 274 forks source link

Keyboard error #213

Open mavillar opened 8 years ago

mavillar commented 8 years ago

Hi,

I have a directive which receives an event to get an input focus and show up the keyboard.

directives.focusMe = function ($timeout, $rootScope) {
        return {
            link: function (scope, element, attrs) {
              $rootScope.$on('focus:search_input', function() {
                  $timeout(function () {
                      element[0].focus();
                      if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
                        cordova.plugins.Keyboard.show();
                      }
                  }, 350);
                  console.info('focused...');
              });
              element.bind("keydown keypress", function (event) {
                  if(event.which === 13) {
                      scope.$apply(function (){
                          scope.$eval(attrs.myEnter);
                      });
                      event.preventDefault();
                  }
              });
            }
        };
}

Neither browser nor iOS, the keyboard do not show up. For instance, when code reach con conditional checking cordova, it arises the following error:

TypeError: Cannot read property 'Keyboard' of undefined

In my plugins directory is: ionic-plugin-keyboard What's happening? What am I doing wrong?