ais-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 lets you configure the credentials for search. This component automatically provides the search state to all its children.
Note that every other Angular InstantSearch widgets must be wrapped under 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
indexName
|
type: string
Required
The main index to search into. |
||
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
A hook that is called each time a search needs to be done, with the helper as a parameter.
It’s your responsibility to call When modifying the state of the helper within When this option is set, |
||
Copy
|
|||
initialUiState
|
type: object
Optional
Adds a
Copy
|
||
onStateChange
|
type: function
Optional
Triggers when the state changes. Whenever you start using this option, the instance becomes controlled. This means that you become responsible for updating the UI state with This can be useful to perform custom logic whenever the state changes. |
||
Copy
|
|||
stalledSearchDelay
|
type: number
default: 200
Optional
Defines a time period after which a search is considered stalled. You can find more information in the slow network guide. |
||
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. You can find more information in the routing guide. The object form accepts two attributes:
|
||
Copy
|
|||
insightsClient
|
type: function
Optional
The function exposed by the |
||
Copy
|
HTML output
1
2
3
<div class="ais-InstantSearch">
<!-- Widgets -->
</div>