我有一段代码,我想切换到“ON”,“OFF”也被翻译,但怎么做?
<label class="toggle modal-label-box">
<input type="radio" name="radio-toggle2" ng-model="faculty" value="7">
<i data-swchon-text="ON" data-swchoff-text="OFF"></i><span translate>SOME</span>
</label>
如果有人对此有任何想法请分享, 此致
答案 0 :(得分:0)
<label class="toggle modal-label-box">
<input type="radio" name="radio-toggle2" ng-model="faculty" value="7">
<i data-swchon-text="ON" data-swchoff-text="OFF"></i>
</label>
否则可能,而不是:
data-swchon-text = "ON" data-swchoff-text = "OFF"
使用:
data-swchon-text = "{{swich.on}}" and data-swchoff-text = "{{swich.off}}"
?
答案 1 :(得分:0)
HTML:
<i ng-switch-on="{{ ON }}" ng-switch-off="{{ OFF }}"></i>
JS:
app.directive('ngSwitchOn', function() {
return function(scope, elem, attrs) {
attrs.$observe('ngSwitchOn', function(data) {
elem.attr('data-swchon-text', data);
});
};
});
app.directive('ngSwitchOff', function() {
return function(scope, elem, attrs) {
attrs.$observe('ngSwitchOff', function(data) {
elem.attr('data-swchoff-text', data);
});
};
});