ais-infinite-hits
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-infinite-hits // Optional parameters showPrevious="boolean" showPreviousLabel="string" showMoreLabel="string" [transformItems]="function" ></ais-infinite-hits>
1
2
3
4
5
6
7
8
import { NgAisInfiniteHitsModule } from 'angular-instantsearch';
@NgModule({
imports: [
NgAisInfiniteHitsModule,
],
})
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-infinite-hits
widget displays a list of results with a “Show more” button at the bottom of the list. As an alternative to this approach, the infinite scroll guide describes how to create an automatically-scrolling infinite hits experience.
To configure the number of hits to show, use one of:
- The
ais-hits-per-page
widget - The
ais-configure
widget and sethitsPerPage
insearchParameters
.
If there are no hits, you should display a message to users and clear filters so they can start over.
Examples
1
<ais-infinite-hits></ais-infinite-hits>
Properties
Parameter | Description | ||
---|---|---|---|
showPrevious
|
type: boolean
default: false
Optional
Enable the button to load previous results. The button is only displayed if the routing option is enabled in |
||
showPreviousLabel
|
type: string
default: "Show previous results"
Optional
The label for the “Show previous” button. |
||
showMoreLabel
|
type: string
default: "Show more results"
Optional
The label for the “Show more” button. |
||
transformItems
|
type: function
default: items => items
Optional
Receives the items and is called before displaying them. It returns a new array with the same “shape” as the original. This is helpful when transforming, removing, or reordering items. The complete If you’re transforming an attribute with the |
||
Copy
|
Templates
Parameter | Description | ||
---|---|---|---|
hits
|
type: object[]
The matched hits from the Algolia API. You can use Algolia’s highlighting feature with the |
||
results
|
type: object
The complete response from the Algolia API. It contains the |
||
isFirstPage
|
type: boolean
Indicates whether the first page of hits has been reached. |
||
isLastPage
|
type: boolean
Indicates whether the last page of hits has been reached. |
||
showPrevious
|
type: function
Loads the previous page of hits. |
||
Copy
|
|||
showMore
|
type: function
Loads the next page of hits. |
||
Copy
|
|||
insights
|
type: function
signature: (method: string, payload: object) => void
Sends Insights events.
|
||
Copy
|
HTML output
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<div class="ais-InfiniteHits">
<button class="ais-InfiniteHits-showPrevious">Show previous results</button>
<ul class="ais-InfiniteHits-list">
<li class="ais-InfiniteHits-item">
...
</li>
<li class="ais-InfiniteHits-item">
...
</li>
<li class="ais-InfiniteHits-item">
...
</li>
</ul>
<button class="ais-InfiniteHits-showMore">Show more results</button>
</div>