ais-instantsearch
Angular InstantSearch isn’t compatible with Angular’s Ivy view engine. We’re investigating how best to support this. For more information and to vote for Algolia’s support of Angular 16 and beyond, see the GitHub issue Algolia Support for Angular InstantSearch
<ais-instantsearch [config]="{ indexName: string searchClient: object // Optional parameters numberLocale: string searchFunction: function initialUiState: object onStateChange: function stalledSearchDelay: number routing: boolean|object insightsClient: function }" ></ais-instantsearch>
1
2
3
4
5
6
7
8
import { NgAisInstantSearchModule } from 'angular-instantsearch';
@NgModule({
imports: [
NgAisInstantSearchModule.forRoot(),
],
})
export class AppModule {}
1. Follow additional steps in Optimize build size to ensure your code is correctly bundled.
2. This imports all the widgets, even the ones you don’t use. Read the Getting started guide for more information.
About this widget
The ais-instantsearch
widget is a wrapper that allows you to configure your search. It provides the search state to all its children.
You must wrap all other Angular InstantSearch widgets inside this one.
Examples
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import algoliasearch from 'algoliasearch/lite';
@Component({
template: `
<ais-instantsearch [config]="config">
<!-- Widgets -->
</ais-instantsearch>
`,
})
export class AppComponent {
config = {
indexName: 'instant_search',
searchClient: algoliasearch('YourApplicationID', 'YourSearchOnlyAPIKey'),
}
}
Props
Parameter | Description | ||
---|---|---|---|
indexName
|
type: string
Required
The main index in which to search. |
||
Copy
|
|||
searchClient
|
type: object
Required
Provides a search client to |
||
Copy
|
|||
numberLocale
|
type: string
Optional
The locale used to display numbers. This is passed to |
||
Copy
|
|||
searchFunction
|
type: function
Optional
This option allows you to take control of search behavior. For example, to avoid doing searches at page load. When this option is set, A hook is called each time a search is requested (with Algolia’s helper API as a parameter). Carry out the search by calling When modifying the state of the helper within |
||
Copy
|
|||
initialUiState
|
type: object
Optional
Adds a Replace |
||
Copy
|
|||
onStateChange
|
type: function
Optional
Triggers when the state changes. This can be useful when performing custom logic on a state change. When using |
||
Copy
|
|||
stalledSearchDelay
|
type: number
default: 200
Optional
A time period (in ms) after which the search is considered to have stalled. Read the slow network guide for more information. |
||
Copy
|
|||
routing
|
type: boolean|object
default: false
Optional
The router configuration used to save the UI state into the URL or any client-side persistence. The object is accepted if it has either of these keys:
For more information, read the routing guide. |
||
Copy
|
|||
insightsClient
|
type: function
Optional
This function is exposed by the |
||
Copy
|
HTML output
1
2
3
<div class="ais-InstantSearch">
<!-- Widgets -->
</div>