I understand that Angular requests the route from the server via AJAX and then sets the browser's URL bar to the new location via the HTML5 history/pushstate methods?
If so, when you request the URL via a page reload, it gets routed by Laravel. Then, Laravel just serves the view that you have configured via your routes (sometimes plain JSON). Which is what you want, but only for Angular's AJAX calls.
I propose you add an isAJAX
filter to your routes. In your filter.php
declare this filter:
Route::filter('isAJAX', function()
{
if (!Request::AJAX()) return Redirect::to('/')->with(array('route' => Request::path()));
});
Then put all your routes that you only want accessible via AJAX into a group. In your routes.php
:
Route::group(array('before' => 'isAJAX'), function()
{
Route::get('contacts/{name}', ContactController@index); // Or however you declared your route
... // More routes
});
This way, only Angular's AJAX calls return results from the database. Every manual page reload is routed back to '/' with a variable route
set to the requested route. You would then have to pick up this route and initiate Angular's router with it.