JnTng
3 days ago

x-component : cannot pass variable in <>

Posted 3 days ago by JnTng

Hello,

I am learning the blade lesson. I try to pass variable title in <>, but it dosen't work.

The content.blade can show "Buy Me a Coffee" and " Laravel 7 Blade Component Note". Why the "Laravel" not show up?

resources/views/content.blade.php

<x-layout title="Laravel">
    <x-slot name="ad">
        Buy Me a Coffee
    </x-slot>

    Laravel 7 Blade Component Note
</x-layout>

resources/views/components/layout.blade.php

<div>
    Hello {{ $title }}
</div>

<div>
    @if( isset($ad) )
        <div class="ad">
            {{ $ad }}
        </div>
    @endif

    <div class="dashboard">
        {{ $slot ?? '' }}
    </div>
<div>

Please sign in or create an account to participate in this conversation.