lundi 2 novembre 2015

Using list index in child component property name

I am working on form based application. I created custom components to handle the form display.

One of the use case I have, is to display a list of object with their properties as the following:

  {{#r-tabs}}
    {{#each buildings as |b index|}}
      {{#r-tabs-panel}}
        {{#r-form-fieldset}}
          {{r-form-control label="egid" property="buildings:0/EGID" value=b.EGID size='md'}}
          {{r-form-control label="bezeichnung" property="buildings:0/description" content=buildingDescriptions size="lg"}}
          {{#r-form-group label="strasse / nr."}}
            {{r-form-control label="strasse" property="buildings:0/streetName" value=b.address.streetName size="lg"}}
            {{r-form-control label="nr." property="buildings:0/streetNum" value=b.address.streetNum}}
          {{/r-form-group}}
          {{r-form-control label="Baujahr" property="buildings:0/yearOfConstruction" value=b.yearOfConstruction}}
          {{r-form-control label="Kubatur" property="buildings:0/cubature" value=b.cubature size="md" unit="m³"}}
          {{r-form-control label="Neuwert" property="buildings:0/value" value=b.value size="md"}}
        {{/r-form-fieldset}}
      {{/r-tabs-panel}}
    {{/each}}
  {{/r-tabs}}

I would like to use the index from the {{#each}} loop in order to make the property dynamic by replacing the hardcoded 0. But I was unsuccessful so far.




Aucun commentaire:

Enregistrer un commentaire