InstantSearch / Angular / V4 / API reference

Ais-Toggle | Angular InstantSearch V4 (Deprecated)

Deprecated content
Angular InstantSearch is deprecated. Please use InstantSearch.js instead. For more information, see Migrating from Angular InstantSearch.

Signature

Signature
<ais-toggle
  [attribute]="string"
  [label]="string"

  // Optional parameters
  [on]="boolean|number|string"
  [off]="boolean|number|string"
></ais-toggle>

Import

1
2
3
4
5
6
7
8
import { NgAisToggleModule } from 'angular-instantsearch';

@NgModule({
  imports: [
    NgAisToggleModule,
  ],
})
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-toggle widget provides an on / off filtering feature based on an attribute value.

Examples

1
2
3
4
<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
></ais-toggle>

Props

attribute

Required
Type: string

The name of the attribute on which to apply the refinement.

To avoid unexpected behavior, you can’t use the same attribute prop in a different type of widget.

1
2
3
4
<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
></ais-toggle>

label

Required
Type: string

Label to display for the checkbox.

1
2
3
4
<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
></ais-toggle>

on

Optional
Type: boolean|number|string

The value of the refinement to apply on the attribute when checked.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
  on="yes"
></ais-toggle>

<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
  [on]="true"
></ais-toggle>

<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
  [on]="1"
></ais-toggle>

off

Optional
Type: boolean|number|string

The value of the refinement to apply on the attribute when unchecked.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
  off="no"
></ais-toggle>

<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
  [off]="false"
></ais-toggle>

<ais-toggle
  attribute="free_shipping"
  label="Free Shipping"
  [off]="0"
></ais-toggle>
Did you find this page helpful?