【问题标题】:Angular 1 - concatenate model with string in expressionAngular 1 - 将模型与表达式中的字符串连接起来
【发布时间】:2017-10-10 18:06:22
【问题描述】:

例如,是否有可能在带有 ecmaScript 2015 的表达式中写入这种文字,我认为尤其是 || 会导致问题

{{ ::$ctrl.realEstateProjectCurrentProduct.housingTax + ' €' || $ctrl.noDataMessage }}

【问题讨论】:

    标签: javascript angularjs ecmascript-6


    【解决方案1】:

    你可以使用角度滤镜

    myApp.filter('xyz', function() {
      return function(input) {
        if(input) {
          return input + ' €';
        } else {
          $ctrl.noDataMessage;
        }
      };
    });
    

    在 HTML 中

    {{$ctrl.realEstateProjectCurrentProduct.housingTax | xyz }}
    

    【讨论】:

      猜你喜欢
      • 2017-04-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多