Laravel Blade and Angular brackets
I use one AngularController.php to render main.blade.php file that then renders angular. The only other blade file is the login page. I could have done this in the routes.php file but since the routes file has the login page I decided to place it in this controller.
<?php namespace App\Http\Controllers;
use Illuminate\Support\Facades\Blade;
use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\View;
use Laracasts\Utilities\JavaScript\Facades\JavaScript;
/**
* @Middleware("auth")
*/
class AngularController extends BaseController {
use UserHelper;
/**
* @var UserService
*/
private $userService;
public function __construct(UserService $userService)
{
$this->userService = $userService;
}
/**
* @Get("behat", as="behat.dash")
*/
public function index()
{
Blade::setContentTags('<%', '%>'); // for variables and all things Blade
Blade::setEscapedContentTags('<%%', '%%>'); // for escaped data
$user_id = $this->getUserId();
$profile = $this->userService->getPerson($user_id);
$token = csrf_token();
$chat_on = Config::get('app.chat_on', true);
JavaScript::put(
[
'pusher_public_key' => $_ENV['PUSHER_PUBLIC'],
'sauce_key' => $_ENV['SAUCE_TOKEN'],
'sauce_user' => $_ENV['SAUCE_USER'],
'profile' => $profile,
'token' => $token,
'debug' => Config::get('app.debug'),
]
);
return View::make('layouts.main', compact('chat_on'));
}
}
Thanks to http://scotch.io/bar-talk/quick-tip-using-laravel-blade-with-angularjs for the tip
comments powered by Disqus