How do we access array elements directly without looping in Templates?

  • I'm looping through an array of patients. Each patient has within it an array of visits. I want to get visits[0] and the elements in that object, but once I add the [0] part, it freaks out. I assume it's handlebars that doesn't like it. The portion of the template looks like this:

    <div class="patientCSN" style="position: absolute; top: 0px; left: 460px;">
        <strong>CSN:</strong> {{visits[0]}}

    I want to access visits[0].p3_csn.

    How do I do this?

  • administrators

    i think you can do {{visits.0.p3_csn}} , in any case make sure to check handlebars docs when you have doubts about what syntax works and what not

  • Never mind. Found it: {{visits.[0].p3_csn}}

Log in to reply

Looks like your connection to jsreport forum was lost, please wait while we try to reconnect.