我的代码很简单,我的html:
<script type="text/x-handlebars" data-template-name="sites">
<ul>
{{#each controller}}
<li>
{{#linkTo 'sites.index' site}} {{siteName}} {{/linkTo}}
</li>
{{/each}}
</ul>
</script>
我的灰烬代码:
WebApp.Router.map(function () {
this.resource('sites', { path: '/' } , function() {
this.route('index', { path: '/:site_id' })
});
});
//returns all Sites to display
WebApp.SitesRoute = Ember.Route.extend({
model: function () {
return WebApp.Site.find();
}
});
WebApp.Site = DS.Model.extend({
id: DS.attr('integer')
});
WebApp.Site.FIXTURES = [
{
id: 1,
siteName: gff1.com
},
{
id: 2,
siteName: gff2.com
},
{
id: 3,
siteName: gff3.com
}
];
我想制作一个链接到的站点列表/sites/index/<ID>
当我运行此代码时,我得到Assertion failed: Cannot call get with 'id' on an undefined object.
了我做错了什么?