📅  最后修改于: 2023-12-03 15:33:07.356000             🧑  作者: Mango
Ngx-Search Clearing is a library for Angular 7+ that provides a simple and easy-to-use search bar component with the ability to clear the input value.
To install ngx-search-clearing, run the following command:
npm install ngx-search-clearing --save
NgxSearchClearingModule
in your AppModule
or feature module:import { NgxSearchClearingModule } from 'ngx-search-clearing';
// ...
@NgModule({
imports: [
// ...
NgxSearchClearingModule
],
// ...
})
export class AppModule { }
ngx-search-clearing
component to your template:<ngx-search-clearing [placeholder]="'Search...'" (search)="onSearch($event)" (clear)="onClear()"></ngx-search-clearing>
export class AppComponent {
onSearch(value: string) {
console.log(`Search: ${value}`);
}
onClear() {
console.log(`Clear`);
}
}
| Input | Type | Default Value | Description |
| ----- | ---- | ------------- | ----------- |
| placeholder | string | 'Search'
| The search input placeholder text |
| buttonIcon | string | 'search'
| The clear button icon name |
| Output | Type | Description |
| ------ | ---- | ----------- |
| search | EventEmitter
Ngx-Search Clearing is a simple and easy-to-use search bar component for Angular applications. With its customizable placeholder text and button icon and the ability to emit events when the search bar value changes or is cleared, it's a great tool for adding search functionality to your application.