This repository's issues are reserved for feature requests and bug reports.
I would like a way to set or clear the search text outside the component and without having to click the X to close the search. There should be some sort of exposed method that allows you to get and set the search input string.
You could achieve this today with something like this.
Extended reply based on https://github.com/Teradata/covalent/issues/182
import { Component, ViewChild } from '@angular/core';
import { TdSearchBoxComponent } from '@covalent/core';
@Component({
selector: 'some-component',
template: `<td-search-box #searchBox backIcon="arrow_back" class="push-right-sm" placeholder="Search" (searchDebounce)="search($event)"
showUnderline="true" flex></td-search-box>`
})
export class SomeComponent {
@ViewChild('searchBar') searchBar: TdSearchBoxComponent;
search($event: string) { ... }
/* You can use the same approach to set the search string */
clearSearchField() {
this.searchBar.value = '';
}
}
Thanks for the nice example.
It was also nice to be able to call this.searchBox.toggleVisibility() to close the search.
We probably need to add more examples in our docs to let developers know all the possible ways our components can be used. (or at least the most frequently asked)
Close, solved @emoralesb05
Yeah, thanks! Adding faqs label
Most helpful comment
We probably need to add more examples in our docs to let developers know all the possible ways our components can be used. (or at least the most frequently asked)