md-select customize label
Hi,
In the previous version of md-select we could specify a custom displayed label with md-select-label It could be a static value or a dynamic one. It was quite useful in two case : 1 - I want a static label 2 - I want a dynamic label, mainly for 'multiple' select (for example "3 items selected")
I don't see any way to achieve this with the new md-input-container + md-select (I really like the new version I just need to be able to implement this in this new version too)
Thanks a lot.
@no-more will talk to the team about re-adding this. Initially we removed it because it can lead to bad UX when options that are selected don't reflect what the user clicked on the menu. Your point regarding multiple is well taken, however.
Can you clarify by what you mean by a "static label" - what is a real world example of this?
Hi,
thanks for your reply, the static label is not really a default use case, in fact I'm using the md-select as a menu with a label as open button and in witch I can select an active option. But when the option is selected I want the default label to still be displayed. I have not yet tried to use the new md-menu to achieve this. It's probably more adapted to my needs.
Thanks.
@no-more You could likely use the placeholder attribute on the md-select to achieve the desired result. Will still discuss regarding the multiple overwrite
Hi, thanks that's exactly what I was looking for.
Hello, I agree with @no-more that this update has taken away desired functionality from the md-select directive. There are cases where customizing the select options could be considered an improvement to the UX. Opinions may vary. Examples...
a select element containing color selections with the color displayed beside the hex code (see pen below). a select element which formats each option text in a different color (red, yellow, green)
Is there a way to configure this with 10.1? I'm currently able to do options with custom markup (as before) but unable to maintain consistency with the selected option since md-select-label has been removed. This creates the inconsistent UX.
It's entirely possible that I'm missing something here. Let me know if anything here requires clarification. Thanks
Here's a modification from a demo codepen demonstrating the behavior: http://codepen.io/anon/pen/rVbLOm
+1
I was going to open a new issue but I found this thread. In my case it is needed because on a multi-language setting you need to be able to change the language on the fly but now it can't, it stays in the previous translation until the select is opened and selected again.
On v0.10.0 (not v0.10.1) you could do:
<md-select class="md-toolbar-tools" ng-model="selected">
<md-select-label>{{ selected.title | translate }}</md-select-label>
<md-option ng-value="opt" ng-repeat="opt in menu">{{ opt.title | translate }}</md-option>
</md-select>
selected.title containing the key to the translation.
That way, if you change the language, the label gets updated.
From v0.10.1 until now, you can't use md-select-label anymore and the alternative (using an md-input-container with a label inside) doesn't mimic that behavior resulting in the label stuck in the language it was when the option was selected.
If someone could point me in the right direction I would appreciate it. Mainly knowing if this feature would be brought back or if there is any other way I could achieve the same result (I was thinking re-rendering the directive on a "translation change" event but I can't figure out how).
Thanks.
@paramburu Try using the translate and/or translate-default attributes on the elements
<md-select id="someSelect" translate>
<md-option ng-value="opt" ng-repeat="opt in someController.options">
<span translate translate-default="{{opt.label}}">{{opt.label}}</span>
</md-option>
</md-select>
@bshir... Just tried it but didn't work. Thanks anyway...
+1
it will be good to have md-select-label back
This is what we wanted to achieve using md-select-label
