Field Ionic search, need to close when user click "Go" or "OK" from Keyboard

Asked

Viewed 530 times

4

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

<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 picking up the ng-model="q" and filtering into:

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

Which works great, but the customer wishes that by clicking on the "Go" or "OK" button on the keyboard, the same will close. How can I do this?

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

  • This ng-Submit="closeTeclate()" was a failed attempt to close the keyboard.

2 answers

1

Use your button with type="submit", so that he can be identified by device and add the go.

<input type="submit" size="100" ng-model="q" placeholder="Procurar" ng-submit="fechaTeclado()" />
  • The "Submit" button is in the entire search bar and does not open the keyboard...

1


The only way it worked was by transforming it into a 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 this, to solve, without changing the layout.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.