How do I apply a filter to refine results creating an Autocomplete custom widget in Angular?

I have created a custom autocomplete using the Algolia guide ( Autocomplete Angular ) works correctly, however I want to apply a filter by categories that has each of the hits.
I don’t want to apply the filter in the HTML using the * ngIf but I want the state.indices to be filtered, where should I apply the filtering or how should I do it?

// So I get the word that I send to the API to get results
    public handleChange($event: KeyboardEvent) { 
    this.destinationWord = ($event.target as HTMLInputElement).value;
    if (this.destinationWord !== '') {
      this.state.refine(this.destinationWord);
    }
  }

Hi there
Thanks for reaching out to us.

I’m sorry but I’m not sure if I understand your question correctly.
I guess you want to use ais-refinement-list.

      <ais-refinement-list attribute="brand"></ais-refinement-list>

Do you want to apply the refinement programmatically without using the component?

As I said I am using the angular api for Algolia, I am using extends BaseWidget.
I have created an autocomplete component that receives the response in state.indeces, how can I put a filter? of the style: state.indices [‘0’]. filter (item => item.category == 0).
I put part of the code

export class AutocompleteComponent extends BaseWidget {
  state: {
    query: string;
    refine: Function;
    indices: object[];
  };

  @Output() onQuerySuggestionClick = new EventEmitter<{ query: string }>();

  constructor(
    @Inject(forwardRef(() => NgAisInstantSearch))
    public instantSearchParent
  ) {
    super('AutocompleteComponent');
  }

  public handleChange($event: KeyboardEvent) {
    this.state.refine(($event.target as HTMLInputElement).value);
  }

  public ngOnInit() {
    this.createWidget(connectAutocomplete, {});
    super.ngOnInit();
  }
}

Reproducing what you currently have would make it easier to help you. We provide an Angular InstantSearch sandbox for this purpose. Could you please reproduce what you currently have and add a comment explaining the expected behavior? Thanks!