Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MdSlider custom thumb label text #4776

Closed
Snesi opened this issue May 24, 2017 · 9 comments
Closed

MdSlider custom thumb label text #4776

Snesi opened this issue May 24, 2017 · 9 comments
Assignees
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix needs: discussion Further discussion with the team is needed before proceeding P4 A relatively minor issue that is not relevant to core functions

Comments

@Snesi
Copy link

Snesi commented May 24, 2017

Bug, feature request, or proposal:

Feature request

What is the expected behavior?

New Inputs in MdSlider to add a suffix or prefix to the thumb-label-text

What is the current behavior?

Thumb label text simply shows a number

What are the steps to reproduce?

Providing a Plunker (or similar) is the best way to get the team to see your issue.
Plunker template: https://goo.gl/DlHd6U

What is the use-case or motivation for changing an existing behavior?

If you want a slider that has a specific unit, like $, or m2 or min.

Which versions of Angular, Material, OS, TypeScript, browsers are affected?

Material 2

Is there anything else we should know?

simply something like this would do:

<span class="mat-slider-thumb-label-text">{{displayPrefix}}{{displayValue}}{{displaySuffix}}</span>
@Snesi
Copy link
Author

Snesi commented May 24, 2017

If I have time to do this I'll create a pull request tomorrow.

@jelbourn jelbourn added discussion feature This issue represents a new feature or feature request rather than a bug or bug fix labels May 24, 2017
@willshowell
Copy link
Contributor

Instead of prefix/suffix, what about something similar to autocomplete's displayWith?

comp.html

<md-slider
 [thumbLabel]="true"
 [displayLabelAs]="labelFn">
</md-slider>

comp.ts

labelFn(value: number): string {
  return `${value} cm`;
}

@Snesi
Copy link
Author

Snesi commented May 25, 2017 via email

@willshowell
Copy link
Contributor

Yeah, I suppose resizing the label and making sure the animation looks right for a dynamic label string would be pretty difficult

@YeomansIII
Copy link
Contributor

Any work being done on this? I can try and implement @willshowell's solution and make a pull request. We need this feature to show slider value as audio track time when dragging. This seems very valuable as it's open to any kind of formatting needed from value to label.

@mmalerba mmalerba changed the title Suffix and Prefix for MdSlider thumb label text MdSlider custom thumb label text Nov 21, 2017
@mmalerba mmalerba added the P4 A relatively minor issue that is not relevant to core functions label Nov 21, 2017
@iget-master
Copy link

iget-master commented Mar 7, 2018

Can someone take a look here? This is an important featore IMO.

For example if you want a slider for a percent value or a currency value.

Edit
Noticed that the version 6 now implements it!. Really waiting for it being published.

iget-master referenced this issue Mar 7, 2018
…el (#10243)

Adds the `displayWith` input on the slider that allows consumers to specify how the thumb label will be formatting. This is useful for cases like very large numbers where the number might be too long for the thumb label.

Fixes #9431.
@mmalerba
Copy link
Contributor

mmalerba commented Mar 7, 2018

Added in #10243

@mmalerba mmalerba closed this as completed Mar 7, 2018
@pantonis
Copy link

Any example of how it works would be good. Currently material does not have any example on how to use displayValue

@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
@mmalerba mmalerba added the needs: discussion Further discussion with the team is needed before proceeding label Mar 3, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue represents a new feature or feature request rather than a bug or bug fix needs: discussion Further discussion with the team is needed before proceeding P4 A relatively minor issue that is not relevant to core functions
Projects
None yet
Development

No branches or pull requests

7 participants