A curious case of ng-focus

This might be more Angular related that Ionic, but it’s worth a shot.

I’m trying to implement a cancel button that appears within the search when the element has been tapped ‘focus’.

When the user taps the button, I want to close the keyboard, and remove the button.

          <i class="icon ion-ios-search placeholder-icon"></i>
          <input type="text" placeholder="Search" ng-model="contactSearch" ng-focus="searchFocus = true">
          <button ng-show="searchFocus" on-touch="clearSearch()" class="button button-energized button-cancel-search">
            Cancel
          </button>

And my clearSearch function

  $scope.clearSearch = function(){
    alert('oi');
    $scope.contactSearch = '';
    $scope.searchFocus = false;
    cordova.plugins.Keyboard.close();
  }

The function is being hit, and the keyboard closes correctly. But for the life of me I cannot force the Cancel button to disappear. Is it not possible to enforce ng-focus in this way?

Any help would be appreciated.

Can you try using ng-if instead of ng-show/ng-hide.