James
James

Reputation: 277

how to pass property value inside another property in polymer?

So I have an array of objects, lets call it searchResults. And I only want to display the object based on the index that is being clicked.

Polymer({
  properties: {
    data: {
      type: JSON,
      value: [],
      observer: 'markerClicked'

    },

    selectedRetailer: {
      type: Number,
      value: 0,
    }
  },



  markerClicked: function(e) {
    this.selectedRetailer += 1;
  }
})
<osb-retailer-details data="{{searchResults.value.selectedRetailer}}">
  <input type="radio" value="[[searchResults.value.selectedRetailer.dealerNumber]]">
</osb-retailer-details>

The above doesnt work and Im not sure why.

Basically, what I want is to pass in the selectedReatailer as the index for the array.

How can I do this?

Thanks

Upvotes: 0

Views: 280

Answers (1)

Michael Stramel
Michael Stramel

Reputation: 1387

There aren't really a lot of details here so I'm just taking a stab at it. I will update my answer if more details are added and this doesn't suite your needs.

<paper-listbox selected-item="{{selectedItem}}">
  <template is="dom-repeat" items="[[searchResults]]">
    <paper-item>[[item.value.selectedRetailer.name]]</paper-item>
  </template>
</paper-listbox>
<osb-retailer-details retailer="[[selectedItem]]"></osb-retailer-details>

Upvotes: 1

Related Questions