Base use-case
Instead of needing a component to use InstantSearch, the instance can be stored in a service, with some utility methods forwarded to the instance. This allows for a single instance to be used across multiple components, and for the instance to be started in a single component.JavaScript
Javascript
ngOnInit
,
and the instance can be started in ngAfterContentInit
in a single component to start the instance.
Connectors can be used to track state changes and bind the data to the component:
JavaScript
HTML
Server-side rendering and routing
With this service, routing works out of the box, by reading the Angular Router’s start state and applying it to the InstantSearch instance. Server-side rendering also works without extra code, as Angular will render the page with the initial state coming from the network request.JavaScript
Multi-index
Multi-index is supported byindex
in the component.
JavaScript