how to pass a variable from livewire to alpine code example
Example 1: share data between livewire and alpine js
You can share data between livewire and apline js using : @entangle
class Counter extends Component
{
public $showDropdown = false;
}
<div x-data="{ open: @entangle('showDropdown') }">
--------------- OR -----------------
<div x-data="{ open: @entangle('showDropdown').defer }">
With this you dont need to use wire model with that data Like
wire:model.defer="showDropdown"
Example 2: passing livewire variable in alpine js
You can share data between livewire and apline js using : @entangle
class Counter extends Component
{
public $showDropdown = false;
}
<div x-data="{ open: @entangle('showDropdown') }">