Failed to apply mascara currency in an if inline

0

I have a condition where I need to apply the money mask.

<td>
    <div class="pull-left">{{nota.issRetido[0] === true ? nota.qtdNotasEmitidas | currency : '-'}}</div>
    <div class="pull-right">{{nota.issRetido[0] === false ? nota.qtdNotasEmitidas| currency  : '-'}}</div>
</td>

When passing ' | currency: 'for condition when true , returns siyntax Syntax Error

However, this error only occurs in the condition of this if inline. How do I put the mask on?

    
asked by anonymous 21.06.2018 / 16:00

1 answer

0
Hello, in the code you are adding the mask to the currency but not by entering the else condition, so to clear any doubts, go to an example using parentheses () to limit the condition:

angular.module('myApp', [])
.controller('myCtrl', function($scope) {
  $scope.nota = {};
  $scope.nota.issRetido = [];
  $scope.nota.issRetido[0] = true;
  $scope.nota.qtdNotasEmitidas = 1;
  });
<html lang="pt-br">
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.5.0/angular.min.js"></script><body><divng-app="myApp" ng-controller="myCtrl">

<h3>Limitando com parênteses e adicionando máscara "currency : '-'"</h3>
<div class="pull-left">{{nota.issRetido[0] === true ? (nota.qtdNotasEmitidas | currency : '-') : '' }}</div>
<div class="pull-right">{{nota.issRetido[0] === false ? (nota.qtdNotasEmitidas | currency:'-') : '' }}</div>

<h3>limitando com parênteses e sem máscara</h3>
<div class="pull-left">{{nota.issRetido[0] === true ? (nota.qtdNotasEmitidas | currency) : '-' }}</div>
<div class="pull-right">{{nota.issRetido[0] === false ? (nota.qtdNotasEmitidas | currency) : '-' }}</div>

</div>
</body>
</html>
    
25.06.2018 / 23:26