Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Conditional template on Polymer 1.0

I'm having trouble applying the new conditional template, in particular with the condition itself, I think.

I've got something like this:

<template is="dom-repeat" items="{{menuitems}}" as="poscol">
    <template is="dom-if" if="{{index != 4}}">
        <div class="positioncolum horizontal layout center wrap flex">
            <span>{{index}}</span>
            <template is="dom-repeat" items="{{poscol}}" as="mitem" >
               <main-menu-item mitem="{{mitem}}"
                   order="{{mitem.TotalOrder}}"
                   onclick="clickMainMenuMod(index)">
               </main-menu-item>
            </template>
       </div>
   </template>
</template>

Now, if I comment the <template is="dom-if" if="{{index != 4}}"> bit it works fine, the index shows as it should. On the fourth array are stored modules that the user has selected as non-visible, so they shouldn't appear on the main menu.

I guess there's something wrong with the if condition, but I can't guess what.

Thanks!

like image 383
Iskalla Avatar asked Jun 10 '15 08:06

Iskalla


1 Answers

Try to modify your conditional template like this:

<template is="dom-if" if="{{show(index)}}">

And add this function to Polymer script:

show: function (index) {
    return index != 4;
}
like image 176
vasek Avatar answered Oct 24 '22 12:10

vasek