How to do auto completion with algolia and angular 2 and higher in a not hackish way?
I got algolia working with angular 2+ but I had to do a few hacks which I would like to avoid if possible:
This is what I did:
declare var algoliasearch: any; declare var autocomplete: any;
II.) The autocomplete methods gets called in a component to add autocompletion to the input field. I am not sure if it is necessary to perform some cleanup or if it is okay if the autocomplete method gets called multiple times.
III.) I included the CSS as external CSS file in the index.html file. The CSS needed to be included as external CSS. If you define it in the component like you would normally do then the final compiled CSS won’t apply to teh generated elements like the suggestions. This is due to angular transforming the CSS into CSS that only applies to elements that belong to the component. Angular does this by having a component specific attribute on the elements of a component. This component specific attribute gets then checked for in the CSS. Algolia generated elements lack this marker attribute so they won’t be styled by the CSS compile result.
Is there a less hackish way to use the algolia auto completion with angular 2 and higher?