问题
I have an md-select in my form with multiple options (same as demo in Angular Material site). It shows a comma separated list of selected options in its input field. Is there any way to change separator? (for example change comma to star or another UTF-8 character).
回答1:
You can do something with pure CSS. You should hide the commas using visibility: collapse
and after that, you can add a Unicode icon with :after
or :before
pseudo-element.
PLUNKER
HTML
<md-select class="my-select" ng-model="vm.selectedItem" multiple>
<md-option ng-value="item.id" ng-repeat="item in vm.items">{{ item.name }}</md-option>
</md-select>
CSS
.my-select[multiple] .md-select-value span:first-child {
visibility: collapse;
}
.my-select[multiple] .md-select-value .md-text {
display: inline-block !important;
visibility: visible;
}
.my-select[multiple] .md-select-value .md-text:not(:last-child):after {
content: '\2605'; /* star */
margin: 0 -5px 0 5px;
}
There you go a list of Glyphs that you can use.
Also, you can add a font-awesome icon with css if you want.
来源:https://stackoverflow.com/questions/46724777/angular-material-change-separator-in-md-select-multiple-option