Answers for "ngx-slider translate"

0

ngx-slider translate

import { Component } from '@angular/core';
import { Options, LabelType } from '@angular-slider/ngx-slider';
    
@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.scss']
})

export class AppComponent {

  dateRange: Date[] = this.customDateRange();
  value: number = this.dateRange[0].getTime();

  constructor() { }

  options: Options = {
    stepsArray: this.dateRange.map((date: Date) => {
      return { value: date.getTime() };
    }),
    translate: (value: number, label: LabelType): string => {
      return new Date(value).toDateString();
    }
  };

  customDateRange(): Date[] {
    const dates: Date[] = [];
    for (let i: number = 1; i <= 31; i++) {
      dates.push(new Date(2021, 6, i));
    }
    return dates;
  }
  
}
Posted by: Guest on June-02-2021

Browse Popular Code Answers by Language