3

I have the following in to show and hide the clear button based upon if the searchQuery is empty or not. When a user starts typing in the input box, the button shows instantly.

However, when the user either clicks the clear button or deletes all input, there is a noticeable lag before the clear button is removed. I have tried ng-show as well, and have received the same results. Any ideas why this lag might exist?

HTML

<button ng-if="search.cardsQuery.length" class="button-icon" ng-click="clearSearchQuery()">
    <i class="ion-android-close search-cards"></i>
</button>

CONTROLLER

$scope.clearSearchQuery = function() {
    $scope.search.cardsQuery = '';
};
robert
  • 819
  • 1
  • 10
  • 24

3 Answers3

4

Check the css class on the element you're applying ng-if/ng-show to. Look for the transition effect. If the class has a transition, it may be the cause to the delay:

.button-icon {
    transition: all .5s;
}
0

Its a common problem seen among the developers. Even trying with ng-if causes the same issue. I can suggest a simple solution for you.

Open your css file for the particular html file and add below line.

**.ng-hide { display: none !important }**

Hope, it will help.

0
$scope.$evalAsync();

Worked for me :)

Abdeali Chandanwala
  • 8,449
  • 6
  • 31
  • 45