0

I'm using custom material autocomplete input for select items in my dynamic form component. As I said fields of form are dynamic and to filter items list I have to change the list every time user type somethin in the input.

filteredOptions: { [key: string]: Observable<PickListItem[]> } = {}; key is the name of controlName and PickListItem is list of items to the select.

In some case user can add theri own option to the list, after that there is API request that returns updated list of items and here is my problem: I want to replace old list with the new one (updated).

Can someone help me?

this.componentsApiService.addPicklistItem(field.Attributes.List.ID, this.addInputOption)
      .pipe(
        finalize(() => {
          this.store.dispatch(new StopLoading('shared.saving'));
        }),
        takeUntil(this.componentDestroyed$))
      .subscribe( result /*updated list*/ => {
        this.filteredOptions[field.Label] = <= here I want to assign observable updated list, dont know how to do this
        this.addInputOption = '';
      }, ({error}) => {
        this.snackBarService.error(error.message);
      });

1 Answer 1

1

you can use rxjs of operator to create an observable

import { of } from 'rxjs';

this.filteredOptions[field.Label] = of(result);
Sign up to request clarification or add additional context in comments.

1 Comment

OR, you can use from operator.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.