Search results

SliderComponent

Represents the EJ2 Angular Slider Component.

<ejs-slider [value]='value'></ejs-slider>

Properties

colorRange

ColorRangeDataModel[]

Specifies the color to the slider based on given value.

cssClass

string

Specifies the custom classes to be added to the element used to customize the slider.

 <ejs-slider id='default' [value]='value' cssClass="slider"></ejs-slider>

 <style>
 .slider {
     border: 1px solid;
 }
 </style>
import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    templateUrl: 'app/template.html',
    styleUrls:['index.css'],
})
export class AppComponent {
    public value: number = 30;
}

Defaults to

customValues

string[] | number[]

Specifies an array of slider values in number or string type. The min and max step values are not considered.

Defaults to null

enableAnimation

boolean

Enable or Disable the animation for slider movement.

Defaults to true

enableHtmlSanitizer

boolean

Specifies whether to display or remove the untrusted HTML values in the Slider component. If ‘enableHtmlSanitizer’ set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.

Defaults to true

enablePersistence

boolean

Enable or disable persisting component’s state between page reloads.

Defaults to false

enableRtl

boolean

Enable or disable rendering component in right to left direction.

Defaults to false

enabled

boolean

Enable or Disable the slider.

Defaults to true

limits

LimitDataModel

Specified the limit within which the slider to be moved. Refer the documentation here to know more about this property.

Defaults to { enabled: false }

locale

string

Overrides the global culture and localization value for this component. Default global culture is ‘en-US’.

Defaults to

max

number

Gets/Sets the maximum value of the slider.

Defaults to 100

min

number

Gets/Sets the minimum value of the slider.

Defaults to 0

orientation

SliderOrientation

Specifies whether to render the slider in vertical or horizontal orientation. Refer the documentation here to know more about this property.

Defaults to ‘Horizontal’

readonly

boolean

Specifies whether the render the slider in read-only mode to restrict any user interaction. The slider rendered with user defined values and can’t be interacted with user actions.

Defaults to false

showButtons

boolean

Specifies whether to show or hide the increase/decrease buttons of Slider to change the slider value. Refer the documentation here to know more about this property.

Defaults to false

step

number

Specifies the step value for each value change when the increase / decrease button is clicked or on arrow keys press or on dragging the thumb. Refer the documentation here to know more about this property.

Defaults to 1

ticks

TicksDataModel

It is used to render the slider ticks options such as placement and step values. Refer the documentation here to know more about this property with demo.

 <ejs-slider id='default' [value]='value' [ticks]="ticks"></ejs-slider>
import { Component } from '@angular/core';

@Component({
    selector: 'my-app',
    templateUrl: 'app/template.html',
    styleUrls:['index.css'],
})
export class AppComponent {
    public value: number = 30;
    public ticks: Object = {
        placement: 'Before',
        largeStep: 20,
        smallStep: 5,
        showSmallTicks: true
    };
}

Defaults to { placement: ‘before’ }

tooltip

TooltipDataModel

Specifies the visibility, position of the tooltip over the slider element.

Defaults to { placement: ‘Before’, isVisible: false, showOn: ‘Focus’, format: null }

type

SliderType

Defines the type of the Slider. The available options are:

  • default - Allows to a single value in the Slider.
  • minRange - Allows to select a single value in the Slider. It display’s a shadow from the start to the current value.
  • range - Allows to select a range of values in the Slider. It displays shadow in-between the selection range.
    <div class="sliderwrap">
        <label class="labeltext">Default Slider</label>
        <ejs-slider id="default" [value]="value"></ejs-slider>
    </div>
    <div class="sliderwrap">
        <label class="labeltext">MinRange Slider</label>
        <ejs-slider id="minrange" [value]="value" [type]="mintype"></ejs-slider>
    </div>
    <div class="sliderwrap">
        <label class="labeltext">Range Slider</label>
        <ejs-slider id="range" [value]="rangevalue" [type]="rangetype"></ejs-slider>
    </div>
import { Component } from "@angular/core";

@Component({
    selector: "my-app",
    templateUrl: "app/template.html",
    styleUrls:["index.css"],
})

export class AppComponent {
    public value: number = 30;
    public rangevalue: Number[] = [30,70];
    public mintype: string = "MinRange";
    public rangetype: string = "Range";
}

Defaults to ‘Default’

value

number | number[]

It is used to denote the current value of the Slider. The value should be specified in array of number when render Slider type as range.

Defaults to null

width

number | string

Specifies the width of the Slider.

Defaults to null

Methods

destroy

Removes the component from the DOM and detaches all its related event handlers. Also it removes the attributes and classes.

Returns void

reposition

It is used to reposition slider.

Returns void

Events

change

EmitType<SliderChangeEventArgs>

We can trigger change event whenever Slider value is changed. In other term, this event will be triggered while drag the slider thumb.

  <div id="default"></div>
  <p>Change Event: </p>
  <div id = "change"></div>
import { Slider } from "@syncfusion/ej2-inputs";
  
  let defaultObj: Slider = new Slider({
    value: 30,
  change: function(args: SliderChangeEventArgs) {
    document.getElementById("change").innerHTML = JSON.stringify(args);
    }
  });
  defaultObj.appendTo("#default");

changed

EmitType<SliderChangeEventArgs>

Fires whenever the Slider value is changed. In other term, this event will be triggered, while drag the slider thumb completed.

created

EmitType<Object>

Triggers when the Slider is successfully created.

renderedTicks

EmitType<SliderTickRenderedEventArgs>

Triggers when the ticks are rendered on the Slider.

    <div id="default"></div>
    import { Slider } from "@syncfusion/ej2-inputs";
    let defaultObj: Slider = new Slider({
        min: 0, max: 100,
        value: 30,
        type: "MinRange",
        ticks: { placement: "Both", largeStep: 20, smallStep: 5 },
        // Handler used to customize tick element
        renderedTicks: (args: SliderTickRenderedEventArgs) => {
            let li: any = args.ticksWrapper.getElementsByClassName("e-large");
            let remarks: any = ["Very Poor", "Poor", "Average", "Good", "Very Good", "Excellent"];
            for (let i: number = 0; i < li.length; ++i) {
                (li[i].querySelectorAll(".e-tick-both")[1] as HTMLElement).innerText = remarks[i];
            }
        }
    });
    defaultObj.appendTo("#default");

renderingTicks

EmitType<SliderTickEventArgs>

Triggers on rendering the ticks element in the Slider, which is used to customize the ticks labels dynamically.

    <div id="default"></div>
    import { Slider } from "@syncfusion/ej2-inputs";
    let defaultObj: Slider = new Slider({
      min: new Date("2013-06-13").getTime(),
      value: new Date("2013-06-15").getTime(),
      max: new Date("2013-06-21").getTime(),
      // 86400000 milliseconds for a day
      step: 86400000,
      renderingTicks: function (args: SliderTickEventArgs) {
          let totalMiliSeconds = Number(args.value);
          // Convert the current milliseconds to the respective date in desired format
          let custom = { year: "numeric", month: "short", day: "numeric" };
          args.text = new Date(totalMiliSeconds).toLocaleDateString("en-us", custom);
      },
      ticks: {
          placement: "After",
          // 2 * 86400000 milliseconds for two days
          largeStep: 2 * 86400000
      },
      showButtons: true
      });
      defaultObj.appendTo("#default");

tooltipChange

EmitType<SliderTooltipEventArgs>

Triggers when the Sider tooltip value is changed.

    <div id="default"></div>
    import { Slider } from "@syncfusion/ej2-inputs";

    let defaultObj: Slider = new Slider({
    min: new Date("2013-06-13").getTime(),
    value: new Date("2013-06-15").getTime(),
    max: new Date("2013-06-21").getTime(),
    // 86400000 milliseconds for a day
    step: 86400000,
    tooltipChange: function (args: SliderTooltipEventArgs) {
        let totalMiliSeconds = Number(args.text);
        // Convert the current milliseconds to the respective date in desired format
        let custom = { year: "numeric", month: "short", day: "numeric" };
        args.text = new Date(totalMiliSeconds).toLocaleDateString("en-us", custom);
    },
    tooltip: {
        placement: "Before",
        isVisible: true
    },
    showButtons: true
    });
    defaultObj.appendTo("#default");