Field search in Ionic, I need to close when the user clicks "Go" or "OK" on the keyboard

4

I have a search field at the top, which is just a filter, like this:

<div class="bar bar-subheader bar-light">
    <label class="item item-input item-floating-label">
        <i class="icon ion-search placeholder-icon"></i>
        <input type="text" size="100" ng-model="q" placeholder="Procurar" ng-submit="fechaTeclado()" />
    </label>
</div>

With the filter catching ng-model="q" and filtering on:

<div class="card" ng-repeat="item in ofertass | filter:q | orderBy:someModel | unique: 'cadastra_oferta_cod_oferta'" ng-init="$last ? fireEvent() : null">

It works very well, but the client wants to close the keyboard by clicking the "Go" or "OK" button on the keyboard. How can I do this?

This filter is already filtering automatically. And it's not a form, it's just an input text.

    
asked by anonymous 23.04.2017 / 13:55

2 answers

1

The only way it worked was by transforming into form:

<form ng-submit="fechaTeclado()">
        <div class="bar bar-subheader bar-light">
            <label class="item item-input item-floating-label">
                <i class="icon ion-search placeholder-icon"></i>
                <input type="text" size="100" ng-model="q" placeholder="Procurar" type="submit" ng-submit="fechaTeclado()" ng-click="fechaTeclado()"/>
                <input type="submit" id="submit" value="OK" ng-click="fechaTeclado()"/>

            </label>
        </div>
        </form>

And with the cordova plugin $ cordovaKeyboard + function:

$scope.fechaTeclado = function () {
        $cordovaKeyboard.close()
    };

Just like that, to solve, without changing the layout.

    
05.05.2017 / 02:28
1

Use your button with type="submit" , so that it is identified by device and add go .

<input type="submit" size="100" ng-model="q" placeholder="Procurar" ng-submit="fechaTeclado()" />
    
04.05.2017 / 21:16