当我致电以下时间时:
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' });
});
});
答案 0 :(得分:1)
您需要为您的路线实施model
和serialize
方法。例如:
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')};
},