In our legacy code, data from a Laravel controller is sent to the view for use with Javascript thusly:
$scope.users = JSON.parse('{!! $users or "{}" !!}');
As you can imagine, since it brings the data in as a big JSON string surrounded by single quotes, if the data has a single quote in it, it breaks.
I'm going to renovate how we do it, but before embarking on such a quest, I wanted to see what methods or best practices to keep in mind, and want to know how other people bring in data from Laravel controllers to Javascript in the view.
from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2lkphar
via IFTTT
Aucun commentaire:
Enregistrer un commentaire