ngx-slider icon indicating copy to clipboard operation
ngx-slider copied to clipboard

Don't translate labels when combined.

Open tstephansen opened this issue 2 years ago • 1 comments

Is there a way to not translate the labels when they are combined?

For example, I want the slider to have a % sign after the min and max values but when they are combined I only want a % sign after the max value.

image

image

tstephansen avatar Apr 06 '22 18:04 tstephansen

@tstephansen You can provide an option: https://github.com/angular-slider/ngx-slider/blob/master/src/ngx-slider/lib/options.ts#L90

  /** Custom function for combining overlapping labels in range slider.
      It takes the min and max values (already translated with translate fuction)
      and should return how these two values should be combined.
      If not provided, the default function will join the two values with
      ' - ' as separator. */
  combineLabels?: CombineLabelsFunction = null;

In your case, something like (untested)

    sliderOptions: Options = {
        floor: floor,
        ceil: ceil,
        combineLabels = (min, max) => { return minValue.replace("%", "") + " - " + maxValue }
    };

Tessmore avatar Apr 23 '22 10:04 Tessmore