Reputation: 895
I'm having trouble understanding how Ember.js routing works and particularly how to use Dynamic Segments from the route.
For example, if you wanted to grab the token off of a reset password page and use that in a form submission, how would you get the token? The code below attempts to print the token on a page as an intermediate step, but it won't render the TokenView. What am doing wrong? Thanks.
window.App = Em.Application.create({});
App.IndexView = Em.View.extend({
template: Em.Handlebars.compile(
'<h1>Index</h1>'
)
});
App.ResetView = Em.View.extend({
template: Em.Handlebars.compile(
'<h1>reset view </h1>'
)
});
App.TokenView = Em.View.extend({
template: Em.Handlebars.compile(
'<h1>token view {{token_id}}</h1>'
)
});
App.Router = Ember.Router.extend({
rootElement:'#content',
location: 'hash',
enableLogging: true,
root: Ember.State.extend({
index: Ember.ViewState.extend({
route: '/',
view: App.IndexView
}),
passwordReset: Ember.ViewState.extend({
route: '/reset',
view: App.ResetView,
token: Ember.ViewState.extend({
route: '/:token_id',
view: App.TokenView
})
})
})
});
App.router = App.Router.create();
App.initialize(App.router);
Upvotes: 0
Views: 1868
Reputation: 9236
You should have a look at the state of the art documentation about Router
which is in-progress but available @ https://emberjs-staging-new.herokuapp.com/guides/outlets#toc_the-router
Upvotes: 1