-1

Hello I am using angular 16 "ngx-bootstrap": "^11.0.2",

I can not set default value means when user select the data from suggestive search and i have saved that value in DB and now when you load this control i want to pre fill selected value Below is the code in HTML

I am using [typeaheadAsync]="true"


 <input [(ngModel)]="search" 
typeaheadOptionField="AgencySearchText" 
[typeahead]="suggestions$"
[typeaheadAsync]="true" 
[typeaheadMinLength]="4" 
[optionsListTemplate]="customListTemplate"
class="form-control" 
[name]="label" 
(keydown)="onTypeaheadKeyPress($event)"
(typeaheadOnSelect)="typeaheadOnSelect($event)" 
[required]="required" 
[disabled]="disabled">
ngOnInit(): void {
    this.suggestions$ = new Observable((observer: Observer<string | undefined>) => {
      observer.next(this.search);
    }).pipe(
      switchMap((query: string) => {
        if (query && query.length > 3) {
          return this.srvAgency.GetSearchAgencyLookup(query)
        }
        return of([]);
      })
    );
  }

I have tried the official site but they do not have such example

https://valor-software.com/ngx-bootstrap/#/components/typeahead?tab=overview.

1 Answer 1

0

The ngmodel for the control is bound to a variable named search. You should be able to just do this.search = "apple"

Sign up to request clarification or add additional context in comments.

Comments

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.