title: Ionic 2 - How To Edit Searchbar Values Programmatically
body: <p>How can I modify an ionic searchbar programatically in Ionic 2? I searched this for a while and did not come across anything that solves it.</p>
  
  <p>I want to access &amp; modify the default methods of the searchbar object from the searchview.ts. (e.g. inside onClear(), call onCancel() &amp; navigate to a different view).
  This is the searchbar in my html file.</p>
  
  <pre><code>&lt;ion-searchbar [showCancelButton]="true" (ionClear)="onClear()"&gt;
  &lt;/ion-searchbar&gt;
  </code></pre>
  
  <p>I want to do something like;</p>
  
  <pre><code>onClear(){
      var searchbar = this.searchbar // reference the search bar in the html file, but how do I get this?
      searchbar.onCancel();
      this.navigateToHome();
  }
  </code></pre>
  
  <p>Thanks in advance for your help!</p>
  
  <p>Edit: added code sample. Modified the example to calling onCancel() from onClear(), instead of vice versa. </p>