dlsso
dlsso

Reputation: 8111

Pass array literal to polymer computed binding

Effort and Research

I would like to pass an array literal to a computed binding in polymer. My attempt looks like this:

if="[[ !isMatch(item.Type, ['Inbox', 'Review', 'Invalid']) ]]"

However, isMatch never gets hit. Passing a single string works fine. The docs mention string and number literals will work but nothing about arrays.

Question

Is there a syntax that will allow me to do this, or is the current solution just a series of nested ifs? Hoping to avoid the latter since it would be less performant.

Upvotes: 1

Views: 163

Answers (1)

dlsso
dlsso

Reputation: 8111

Suggestion from Tomasz seems like a good option. I added the array in my polymer properties section, then used it in my conditional.

In Polymer properties

  umoveableCategories: {
    type: Array,
    readOnly: true,
    value: ['Inbox', 'Review', 'Invalid']
  }

The updated conditional

if="[[ !isMatch(item.Type, umoveableCategories) ]]"

Upvotes: 1

Related Questions