I am using ngx-bootstrap library (Angular6, Bootstrap4) for typeahead component. It works well when we start typing in. But I want to achieve following:
User has different choices . say: ai, ax, az etc.. User chooses one and typeahead should automatically start searching on selected text. This means users does not have to type anything in the input box to start searching,
Just click one of the options, typeahead will present with available choices and user can select the precise option.
So basically, I want to avoid typing manually in the text box and trigger typeahead population event through code.
Can I achieve that ?
Thanks in advance,
Venky
sorry if i'm late but i found now this question, maybe it can be useful in future. The typeahead wait for an input event. You can trigger the event in this way:
const element: HTMLElement = document.getElementById('my-typeahead') as HTMLElement;
const event = new Event('input', {
'bubbles': true,
'cancelable': true
});
element.dispatchEvent(event);
where 'my-typeahead' is the id of the input you are using as typeahead. In this way the search will start.