I have the following code in my angular app.
app.config(function($routeProvider, $locationProvider) {
$locationProvider.html5Mode(true);
$routeProvider
.when("/users/:u_id/restaurants/:r_id/menus/:m_id/sections/:sec_id/items", { templateUrl: "/assets/menus/items.html", controller: "MenuItemCtrl" })
});
It works fine when I navigate to the path using
<a href="./sections/{{section.id}}/items">View Items</a>
But when I refresh the page or go directly to the url it throws a rails routing error
No route matches [GET] "/users/3/restaurants/3/menus/4/sections/4/items"
If I create this route in routes.rb it just returns the JSON associated with the response and does not route to the correct template.
Does anyone know how to fix this issue?
get '(*url)' => 'home#index'
In this example the home_controller's index() method serves up the single page app. See this answer for details. – Sunil D. Apr 9 at 4:56