Hi,
How to use NbSearchService in different components?
Hey @aciechomski, could you elaborate? You can inject it in any component as any other Angular service.
What I doing wrong? When Nb-search is in diffrent component (HeaderComponent).
export class ListComponent implements OnInit, OnDestroy {
subscription: Subscription;
constructor(
private searchService: NbSearchService) {
}
ngOnInit() {
this.subscription = this.searchService.onSearchSubmit().subscribe((data: { term: string, tag: string }) => this.search() );
}
public search() {
}
ngOnDestroy() {
this.subscription.unsubscribe();
}
}
@aciechomski would you mind providing a complete example? What is expected behavior, are there any errors? It's really hard to tell if there are any issues with the code without that info.
Example on ngx-admin.
Component: smart-table.component.ts
constructor(private service: SmartTableService,
private search: NbSearchService) {
search.onSearchSubmit().subscribe(data => this.Filter(data.term) )
const data = this.service.getData();
this.source.load(data);
}
private Filter(text)
{
console.log(text);
}
Why upper search not working?
Pls answer my question.
@aciechomski have you solve the problem?
Most helpful comment
What I doing wrong? When Nb-search is in diffrent component (HeaderComponent).