【发布时间】:2014-01-06 16:42:42
【问题描述】:
我正在尝试开发一个涉及我当地跑步团体比赛结果的网络应用程序。 Ember.js 看起来是一个很好的网站开发框架。
此时此刻我的代码:
App.Router.map(function() {
this.resource('results', function(){
this.resource('year');
});
});
App.ResultsRoute=Ember.Route.extend({
model: function() {
return $.getJSON("../api/api.php?method=years");
//returns a JSON array with all the years a certain race went through => [{"year":"2008"},{"year":"2009"},{"year":"2010"}]
},
});
App.YearRoute=Ember.Route.extend({
model: function(params){
//some horrible code
}
});
在我网站的左侧,所有年份都显示在列表中。 当我点击一年时,比赛结果出现在右侧。
当我点击 2008 年时,如何调整 Router.map 以使 url 看起来像“www.example.com/index.html#/results/2008”?
作为一个菜鸟程序员,我很难弄清楚这一点。
【问题讨论】:
标签: javascript dynamic ember.js