简体   繁体   English

在emberjs中遇到动态片段的问题

[英]having trouble with dynamic segments in emberjs

This should be simple to do. 这应该很简单。 I just can't pass the value of the input to the product-details view. 我只是不能将输入的值传递到产品详细信息视图。 I'm trying to create a unique template page for each item added to the list. 我正在尝试为添加到列表中的每个项目创建一个唯一的模板页面。 Clicking the 'details' link should take the user to the unique page. 单击“详细信息”链接应将用户带到唯一页面。 I understand how dynamic segments works, I'm just getting stuck somewhere. 我了解动态细分的工作原理,只是陷入了困境。

Thanks! 谢谢!

http://emberjs.jsbin.com/midivu/1/edit?html,js,output http://emberjs.jsbin.com/midivu/1/edit?html,js,output

In your link to helper you need to pass the parameter in... 在你的助手链接中你需要传递参数...

{{#link-to 'details' name class="add-item-button"}}

Example.. If you imagine link-to as a function then in your case it would be 示例..如果您想将链接作为一个函数,那么在您的情况下它将是

linkTo(route, segment, etc...)

But imagine it this way just to understand the adding parameter... 但想象一下这只是为了理解添加参数......

To fix your Details Route 解决您的详细信息路线

App.DetailsRoute = Ember.Route.extend({
    model: function(params) {
        return userList.findBy('name', params.itemName); // assuming you want to find the details by it's name
    }
});

This is because you did not create a data store. 这是因为您没有创建数据存储。 You are using a global variable as your data store, therefore, you must get it from the global. 您正在使用全局变量作为数据存储,因此,您必须从全局变量获取它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM