Ember.js 使用Ember Pre4连杆至把手

Ember.js 使用Ember Pre4连杆至把手,ember.js,Ember.js,我在让linkTo Handlebar助手工作时遇到问题 我有一个路线设置: this.resource("contact", function(){ this.route('new'); this.route('show', { path: "/:contactid" }); this.route('edit', { path: "edit/:contactid" }); } 在我的模板中,我有以下代码: {{#each e

我在让linkTo Handlebar助手工作时遇到问题

我有一个路线设置:

   this.resource("contact", function(){
        this.route('new');
        this.route('show', { path: "/:contactid" });
        this.route('edit', { path: "edit/:contactid" });   
    }
在我的模板中,我有以下代码:

{{#each entry in controller.entries}}
{#linkTo "contact.show" entry href="true" }}test {{firstname}} {{lastname}}{{/linkTo}}
{{/each}}
结果链接为/contact/show/undefined

我做错了什么


旁注:我没有使用Ember.Data和模型。

Ember希望参数遵循约定
modelname\u id
,因此路由应更改为:

this.resource("contact", function(){
    this.route('new');
    this.route('show', { path: "/:contact_id" });
    this.route('edit', { path: "edit/:contact_id" });   
}
假设定义了
entry.get(“id”)
,这应该是可行的


有关详细信息,请参见。

Ember希望参数遵循约定
modelname\u id
,因此路线应更改为:

this.resource("contact", function(){
    this.route('new');
    this.route('show', { path: "/:contact_id" });
    this.route('edit', { path: "edit/:contact_id" });   
}
假设定义了
entry.get(“id”)
,这应该是可行的


有关详细信息,请参阅。

在路由器中实现序列化以覆盖id的默认行为。例如,我有一个路由,看起来像:

this.route( 'date', { path: '/:begin/:end'} );
路线看起来像

Em.Route.extend( {
    serialize: function( model, params ) { 
        return { begin: model.begin.valueOf(), end: model.end.valueOf() };
    }
} );

在路由器中实现序列化以覆盖id的默认行为。例如,我有一个如下所示的路由:

this.route( 'date', { path: '/:begin/:end'} );
路线看起来像

Em.Route.extend( {
    serialize: function( model, params ) { 
        return { begin: model.begin.valueOf(), end: model.end.valueOf() };
    }
} );