Open numeric keypad automatically

2

I have a page with a numeric input with autofocus:

<input type="number" placeholder="Informe" ng-model='leitura.leituraatual' required="true" autofocus="true">

The problem is that the keyboard appears in Text mode instead of numeric mode. Only the numeric keypad appears if I click on the input manually.

    
asked by anonymous 08.09.2015 / 22:45

2 answers

1

I found it!

I used the plugin cordova-android-focus-plugin

<input id="txtLeituraAtual" type="number" >

JS:

$scope.$on('$ionicView.enter', function(){ 
    var txt=$window.document.getElementById("txtLeituraAtual");
    cordova.plugins.Focus.focus(txt);
});

Now the input receives focus and opens the numeric keypad correctly!

    
09.09.2015 / 15:39
0

Add the tag below in the file config.xml

<preference name="KeyboardDisplayRequiresUserAction" value="false" />

And then, on the controller, call the focus() method of the input just after everything is done.

 $scope.init = function() {
     INPUT_AQUI.focus();
 }

 ...

 $scope.init();
    
09.09.2015 / 00:19