Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

polymer string concatenation for template repeat in v 1.0

Tags:

polymer

I'm not sure if the following is possible with a "computed" and a dom-repeat template. I was binding with child and parent properties prior to .9/.8/1.0

<template is="dom-repeat" as="agreementTypeCount" index-as="agreementTypeCountI" items="{{agreementTypeCounts}}">
  <a href="/{{style_domain}}/agreements/#/table/country/{{selectedCountryCode}}/type/{{agreementTypeCount.type}}/sort/start-desc/size/10/page/1/">{{agreementTypeCount.type}}</a>
</template>

Are there any plans to implement string concatenation? It would make life so much easier!

like image 550
Tim.Willis Avatar asked May 29 '15 21:05

Tim.Willis


1 Answers

It's currently on the roadmap. However you can also use computed bindings for this.

<template is="dom-repeat" as="agreementTypeCount" index-as="agreementTypeCountI" items="{{agreementTypeCounts}}">
  <a href$="{{computeAgreementUrl(style_domain, selectedCountryCode, agreementTypeCount.type)}}">{{agreementTypeCount.type}}</a>
</template>

and then declare it

Polymer({
  ...
  computeAgreementUrl(styleDomain, countryCode, type){
    return "/"+styleDomain+"/agreements/#/table/country/"+countryCode+"/type/"+type+"/sort/start-desc/size/10/page/1/";
  }
})

Please take note of the $ character next to href. It is recommended that you use attribute binding ($=) to native elements' attributes.

like image 54
Neil John Ramal Avatar answered Oct 21 '22 10:10

Neil John Ramal