Terry
Terry

Reputation: 3

Alpinejs x-show syntax issue

I am filtering a grid of logos based on a category that is contained in an array of data. I am having trouble getting the syntax correct for pulling the category into the x-show directive. Here is what I have that is not working-

x-show="tab === '${item.cat}' || tab === 'all'"

Can someone please show me what the correct syntax would be?

Upvotes: 0

Views: 676

Answers (1)

Dauros
Dauros

Reputation: 10577

Inside a directive you use regular JS, therefore:

x-show="tab === item.cat || tab === 'all'"

Or use backticks (`) for template literals.

Upvotes: 1

Related Questions