The polymer defines the last element for dom-repeat elements

I am trying to create breadcrumbs from an array of strings. I have an array property called taxonomyand it looks like ["categories", "clothing", "men", "suits"]. Using dom-repeatas follows:

<template is="dom-repeat" items="{{taxonomy}}" id="breadcrumbs">
  <span>{{item}}</span><span hidden$="[[computeSpanHidden]]"> > </span>
</template>

The resulting view is as follows:

Categories> Clothing> Men> Costumes>

I would like to delete the last to get something like this:

Categories> Clothing> Men> Costumes

I tried to do this by attaching to the hidden attribute of the range that I want to hide, but I'm stuck. An incomplete function is computeSpanHiddenas follows:

computeSpanHidden: function(){
  if(this.taxonomy.slice(-1)[0] == /**the value i want to know how to get **/)
    { return true; } 
      else 
        { return false; }
}
+4
source share
1

index . .

. . ( , )

<span>{{item}}</span><span hidden$="[[computeSpanHidden(index)]]"> > </span>

computeSpanHidden: function(index){
  console.log(index);
  if(this.taxonomy.length - 1 === index)
    { return true; } 
  else 
    { return false; }
}
+3

Source: https://habr.com/ru/post/1605645/


All Articles