【发布时间】:2012-07-25 22:39:04
【问题描述】:
在某些情况下,我遇到了路由 url 的问题。这是我的路由器:
contacts: Em.Route.extend({
route: '/contacts',
index: Em.Route.extend({
route: '/',
connectOutlets: function(router, context) {
App.contactsController.populate()
var appController = router.get('applicationController');
appController.connectOutlet('contactsList');
}
}),
show: Em.Route.extend({
route: '/:contactid',
connectOutlets: function(router, context) {
alert('show contact');
}
}),
doShowContact: function(router, event){
router.transitionTo('show', {contactid: event.context.id});
}
}),
当我进入 doShowContact 时,如果我将 'contactid' 指定为上下文,将 '/:contactid' 指定为“show”内的路由,我会得到例如'/contacts/3' 在浏览器 url 中,一切正常。
但是在 doShowContact 中,如果我指定 'contact_id' 而不是 'contactid' 作为上下文并且 '/:contact_id' 而不是 '/:contactid' 作为路由。我会在浏览器 url 中得到 '/contacts/undefined'。
有没有办法解释?谢谢!
【问题讨论】: