I am facing an issue with an input field that uses the "filtro3" model. When I click on it, I want to clear its contents. The following code works as expected:
<input type="text" ng-model="filtro3" placeholder="Buscar" ng-click="filtro3 = null">
However, when I try to achieve the same functionality using a function, it does not work:
<input type="text" ng-model="filtro2" placeholder="Buscar" ng-click="actualizaCombo()">
$scope.actualizaCombo = function() {
console.log('actualizaCombo');
console.log('filtro2 before='+$scope.filtro2);
$scope.filtro2 = null;
console.log('filtro2 after='+$scope.filtro2);
}
When I execute the function, the console output is as follows:
actualizaCombo
filter2 before = undefined
filter2 after = null
When I type "as":
actualizaCombo
filter2 before = null
filter2 after = null
However, the input field does not get cleared and continues to display "as". Can anyone point out what I am missing or what is going wrong? Thank you.