Class Switch

A class that represents a switch that can be turned on and off.

@ extends Widget implements ValueWidget

Hierarchy (view full)

Implements

Constructors

  • Create a new switch.

    Parameters

    • Optional label: string = ''

      The label text.

    • Optional checked: boolean = false

      Whether the switch is initially checked.

    • Optional callback: Function = null

      The callback function to call when the switch is changed.

    Returns Switch

Properties

id: string
inputRef: HTMLInputElement
labelRef: HTMLSpanElement
listeners: {
    [key: string]: Function[];
}

Type declaration

  • [key: string]: Function[]
ref: HTMLLabelElement
sliderRef: HTMLSpanElement
value: any
view: View

Methods

  • Bind a property to the switch.

    Parameters

    • obj: any

      The object to bind the property to.

    • prop: string

      The property to bind.

    Returns this

  • Get whether the switch is checked.

    Returns boolean

  • Set the callback function to call when the switch is changed.

    Parameters

    • func: Function

      The callback function to call when the switch is changed.

    Returns this

  • Set the label of the switch.

    Parameters

    • label: string

    Returns this