【发布时间】:2018-02-19 12:02:01
【问题描述】:
我有一个开关小部件,它使用自定义数据属性值来标记自己。
.switch.switch-text .switch-label::before {
right: 1px;
color: #c2cfd6;
content: attr(data-hide);
}
.switch.switch-text .switch-label::after {
left: 1px;
color: #c2cfd6;
content: attr(data-show);
opacity: 0;
}
.switch.switch-text .switch-input:checked ~ .switch-label::before {
opacity: 0;
}
.switch.switch-text .switch-input:checked ~ .switch-label::after {
opacity: 1;
}
<label class="switch switch-text switch-pill switch-primary">
<input type="checkbox" class="switch-input" checked>
<span class="switch-label" attr.data-show="{{GLOBALS.ACTIONS.SHOW | translate}}" attr.data-hide="{{GLOBALS.ACTIONS.HIDE | translate}}"></span>
<span class="switch-handle"></span>
</label>
但它只是不起作用。我已经查看了与类似问题相关的不同答案,但有些人说它有效,有些人说它没有。如果我没有 attr 的用户。在前面我得到一个绑定错误,因为它无法识别该属性。
如何使用角度翻译来翻译自定义属性的值?
【问题讨论】:
标签: angular angular-translate custom-attribute