简体   繁体   English

替换 md-select 分隔符

[英]Replace md-select separator character

When md-select is used with multiple option, and multiple options are selected it separates the them using commas.当 md-select 与多个选项一起使用时,并且选择了多个选项,它使用逗号分隔它们。 I want to apply custom styling to the selected options which are being displayed and therefore want to get rid of the automatically added comma characters.我想将自定义样式应用于正在显示的选定选项,因此希望摆脱自动添加的逗号字符。
I checked this stackoverflow question but it is not working for me, the accepted answer, targets those characters(ie commas) by using a pseudo selector :after but the template code which md-select generates for my code is not able to be targeted by this pseudo selector :after , the reason for that is the commas are not a part of md-text 's content.我检查了这个stackoverflow问题,但它对我不起作用,接受的答案是通过使用伪选择器来定位这些字符(即逗号) :after但是 md-select 为我的代码生成的模板代码不能被定位这个伪选择器:after ,原因是逗号不是md-text内容的一部分。

Below is the generated template code which md-select value is selected下面是选择 md-select 值的生成模板代码

<md-select-value class="md-select-value" id="select_value_label_62"><span><div class="md-text ng-binding">
Option1
</div>, <div class="md-text ng-binding">
Option2
</div>, <div class="md-text ng-binding">
Option3
</div></span><span class="md-select-icon" aria-hidden="true"></span></md-select-value>

I want to get rid of the commas placed after ending div tags.我想摆脱在结束div标签之后放置的逗号。 The commas are not wrapped in any html tag with which I can target them and that makes me stuck in this situation since I cannot style them in anyway using CSS.逗号没有包含在任何 html 标签中,我可以用它来定位它们,这让我陷入了这种情况,因为无论如何我都无法使用 CSS 设置它们的样式。
Their only wrapper tag is md-select-value and this cannot help in targeting those sparsely placed commas.他们唯一的包装标签是md-select-value ,这无助于定位那些稀疏放置的逗号。
Any help is appreciated.任何帮助表示赞赏。 Thanks!谢谢!

You can use the md-selected-text API (demo from the docs ).您可以使用md-selected-text API来自文档的演示)。 Note that there is also an API for md-selected-html .请注意, md-selected-html还有一个 API 。

Here's a working example using the |这是一个使用|工作示例separator char with md-selected-text .带有md-selected-text分隔符。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM