0

I have something like this in JSP:

<td>${job.invoiced ? "Y" : "N" }</td>

How would I do something equivalent in Polymer 1.0:

<td>{{job.invoiced ? "Y" : "N"}}</td>  <!-- does not work -->
Dave Ford
  • 1,956
  • 5
  • 19
  • 25

1 Answers1

2

One way to solve the problem is to define a JS function called iff and then use that in your expression:

<td>{{iff(j.invoiced, "&#9679;" ,"&#9675;")}}</td>

Here is how I defined the iff function:

<script>
    Polymer({
        is: "job-audit",
        properties: {
            jobs: {
                type: Array,
                notify: true
            }
        },
        iff(test,t,f){
            return test?t:f;
        }
    });
</script>
Dave Ford
  • 1,956
  • 5
  • 19
  • 25