简体   繁体   中英

How to set javascript variable to laravel blade file?

I am not able to set my javascript variable for my blade file:

$filterCoupons = data;

I want to use this variable in a loop.

You can do this

<script>
    let data = {{json_encode($filterCoupons)}}
</script>

Or you can put all filters into array

var data = [ {{ implode(",", $filterCoupons )}} ];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM