【问题标题】:pascalprecht.translate how translate message with parameter?pascalprecht.translate 如何翻译带有参数的消息?
【发布时间】:2014-11-30 01:51:50
【问题描述】:

我有一段代码,我想切换到“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>

如果有人对此有任何想法,请分享, 问候

【问题讨论】:

    标签: angularjs translate


    【解决方案1】:

    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);
            });
        };
    });
    

    【讨论】:

      【解决方案2】:
      <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}}"?

      【讨论】:

        猜你喜欢
        • 2016-05-07
        • 1970-01-01
        • 2015-07-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-06-01
        • 1970-01-01
        相关资源
        最近更新 更多