2

当我调用以下内容时:

this.get('controller').transitionToRoute('dashboards.submenu',  {dashboard_id: "31", item_id: "97", subitem_id: "11"} );

我也试过:

this.get('controller').transitionToRoute('dashboards.submenu',  dash, item, subitem);

没有成功...

我的网址是这样的:

localhost:9000/#/dashboards/undefined/undefined/undefined

不幸的是,我希望它是

localhost:9000/#/dashboards/31/97/11

知道为什么吗?

如果我直接去

localhost:9000/#/dashboards/31/97/11

它工作正常....

这是我的路由器……

App.Router.map(function () {
    this.resource("index",  { path: "/" });

    this.resource("dashboards",  { path: "/dashboards" } , function(){
               this.route("main", { path: '/' });
               this.route("index", { path: '/:dashboard_id' });
               this.route("submenu", { path: '/:dashboard_id/:item_id/:subitem_id' });
    });
});
4

1 回答 1

1

您需要为您的路线实现这两个modelserialize方法。例如:

model: function(params) {
  return Ember.Object.create({dashboard_id: params.dashboard_id, item_id: params.item_id, subitem_id: params.subitem_id});
},

serialize: function(model) {
  return {dashboard_id: model.get('dashboard_id'), item_id: model.get('item_id'), subitem_id: model.get('subitem_id')};
},
于 2013-04-14T03:19:20.547 回答