code: function handleSearchText(searchText, previousSearchText) {
        self.index = -1;
        // do nothing on init
        if (searchText === previousSearchText) return;
        else if (self.selectedItem && self.displayProperty1) {
          setLoading(false);
          if (self.selectedItem[self.displayProperty1] !== searchText) {
            self.selectedItem = null;
            self.hidden = shouldHide();
            if (self.itemList && self.itemListCopy) {
              self.itemList = angular.copy(self.itemListCopy);
            }
          }
        }
        else if (self.remoteMethod) {
          fetchResults(searchText);
        }
        else if (self.itemList) {
          self.itemList = $filter('filter')(self.itemListCopy, searchText);
        }
      }
docs: Handles changes to the searchText property.
  @param searchText
  @param previousSearchText