I have a problem with adding a simple route and am not sure how to debug it.
I have a route specified as follows
Videos.Router.map(function({
this.resource('videos', {path:'/');
this.route('forms');
})
Videos.FormsRoute = Ember.Route.extend({
renderTemplate: function({
this.render({controller: 'forms'});
}
})
I also have a form template as follows:
<script type="text/x-handlebars" data-template-name="forms">
But when I navigate to the url /forms I get an error of page not found.
Any ideas where I could start looking to solve this?
To use non-hash urls like /forms
you need to configure Ember's location to use html5 location.
App.Router.reopen({
location: 'history'
});
You will also need to configure your server to render the same index.html that is rendered when you visit /forms
. This will vary as per your server.
For apache you'll need a mod_rewrite
rule. For something like rails you need to add a catch all route to use your HomeController
's index page. Something like this at end of your routes.rb,
root :to 'home#index'
match "/*path" => 'home#index'
This tells the server that anything that doesn't match your previous routes should be rendered with HomeController.index
method, or the specific controller that is rendering your application html.
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.