我有一个看起来像这样的链接
index.html#/calendar/year/month
这就是我设置路线的方式:
App.Router.map(function() {
this.resource('calendar', {path: 'calendar/:currentYear/:currentMonth'});
});
App.CalendarRoute = Ember.Route.extend({
model: function (params) {
var obj = {
weeks: calendar.getDaysInMonth(params.currentMonth, params.currentYear),
currentMonth: params.currentMonth,
currentYear: params.currentYear
};
return obj;
},
setUpController: function(controller, model) {
controller.set('content', model);
}
});
我可以这样做:
var currentMonth = this.get('content.currentMonth');
var nextMonth = parseInt(currentMonth)+1;
var route = '#/calendar/'
var year = this.get('content.currentYear');
window.location.href= route + year + '/' + nextMonth;
但我想改用路由器。
我试过了:
var router = this.get('target');
router.transitionTo('#calendar/'+year + '/' + nextMonth);
但我得到这个错误:
未捕获的错误:断言失败:找不到路由#calendar/2013/5
我也试过:
var router = this.get('target');
router.transitionTo('calendar/'+year + '/' + nextMonth);
但这也给了我一个错误:
未捕获的错误:断言失败:找不到路由 calendar/2013/5
编辑:在上面显示我的路由