zyzmoz
February 9, 2018, 4:10pm
1
Hi,
I’m stuck on a functionality, I have to execute a function while the user press the keys inside a input. I have tried ‘ng-change’, ‘onChange’ and others without success. I also tried use $watch, but that just work on the first entry…
Can anyone help me?
jaydz
February 9, 2018, 4:33pm
2
Have you tried
(ionChange)=“changeFunction()”/>
Or, with inputs, the correct action might be
(ionInput)=“changeFunction($event)”/>
I can’t recall exactly at the moment, but I believe option # 2 should do the trick
zyzmoz
February 9, 2018, 4:51pm
3
Thanks to answer but none worked for me…
So, Is this supposed to work on v1 code? Because it seems like ionic/ng 2 syntax…
jaydz
February 9, 2018, 4:56pm
4
You know, I didn’t even notice you had posted under v1. Sorry about that one.
It should work. Can you paste your code or do you have a codepen?
zyzmoz
February 12, 2018, 1:04pm
6
<div class="col" >
<div class="row">
<div class="list search-box">
<div class="item item-input-inset">
<select ng-model="filtro.selected" ng-change="setGrupo()" ng-options="grupo.DESCRICAO for grupo in listaGrupos"
class="xl-filtro item button button-positive icon-right icon ion-android-arrow-dropdown" style="min-width: 155px; margin-right: 5px;" >
</select>
<select ng-model="filtro.selected" ng-change="setGrupo()" ng-options="grupo.DESCRICAO for grupo in listaGrupos"
class="sm-filtro item button button-positive icon-right icon ion-android-arrow-dropdown" style="max-width: 85px; margin-right: 5px; font-size: 10px;" >
</select>
<label class="item item-input-wrapper">
**<input type="text" ng-model="search" (ionInput)="getValue($event)" placeholder="Buscar Produto {{filtro.text}}"/>**
</label>
<button class="btn-limpar button button-assertive" ng-disabled="!search" ng-click="setGrupo(); search = ''">
Limpar
</button>
</div>
</div>
</div>
however in the highlighted input the function isn’t working… getValue function has just a console.log to test proposes!
Just to be clear I’m using Ionic V1 in this project
Thanks in advance
It may be because of (ionInput) attribute.
I did this on codepen and it works.
1 Like
zyzmoz
February 12, 2018, 4:02pm
8
Thanks! I fixed it a couple of minutes ago! But its was exactly what you said!
Thank you for help me!