NpnSlider (A Multi Range Slider Angular Component)
NpnSlider is reusable multi range slider component using Angular v6.0
View on Github
Usage
Html
<npn-slider [min]="2006" [max]="2020" (onChange)="onSliderChange($event)"></npn-slider>
Attributes
Attributes | Description |
---|
@Input() min: number | The minimum value of slider |
@Input() max: number | The maximum value of slider |
@Input() step: number | The value at which slider value should change |
@Input() showStepIndicator: boolean | Whether the step indicator should display or not |
@Input() minSelected: number | The selected value for slider's left handler |
@Input() maxSelected: number | The selected value for slider's right handler |
@Input() disabled: string | To disable the slider. Valid values: 'true' or 'disabled' |
@Output() onChange: EventEmitter<number[]>() | The event will be fired on change of selected range of values. Returns: Selected range of values as an array[] |
Example and Sample Code
a) Import 'NpnSliderModule' in your app module
import { NpnSliderModule } from "npn-slider";
@NgModule({
imports:[
..
NpnSliderModule
..
]
})
b) Add 'npn-slider' in your component html
<npn-slider [min]="1000" [max]="5000" (onChange)="onSliderChange($event)" [step]="500" [showStepIndicator]="true"></npn-slider>
c) Add a method in your component class to listen for onChange event from slider
onSliderChange(selectedValues: number[]) {
this._currentValues = selectedValues;
}
d) You done. Run your app. cheers!