[英]User Update Page In Meteor
Im trying to implement an user update page in my Meteor app. 我正在尝试在我的Meteor应用中实现用户更新页面。 My
router.js
: 我的
router.js
:
Router.route('/company/:_id/update/', {
name: 'CompanyUpdate',
data: function() { return Meteor.users.findOne(this.params._id);}
});
The URL I use is (ignore the polymer tags): 我使用的网址是(忽略聚合物标签):
<paper-icon-button icon="perm-identity" onclick="location.href='{{pathFor 'CompanyUpdate' _id=userId}}'"></paper-icon-button>
When that URL is clicked, I get: http://localhost:3000/company/null/update
. 单击该URL时,我得到:
http://localhost:3000/company/null/update
。 It takes me to the page but I cant get no information from the user's database. 它带我到该页面,但无法从用户数据库中获取任何信息。 Not sure why I get a "null" in the url.
不知道为什么我在URL中得到一个“空”。
I am still learning meteor and would like someone to explain what is missing or doing wrong. 我仍在学习流星,并希望有人解释丢失或做错的事情。
userId
in your template in null. 模板中的
userId
为null。 Try using the default {{currentUser}}
template which calls Meteor.user()
. 尝试使用默认的
{{currentUser}}
模板,该模板调用Meteor.user()
。 So something like this should work: 所以这样的事情应该工作:
<paper-icon-button icon="perm-identity" onclick="location.href='{{pathFor 'CompanyUpdate' _id=currentUser._id}}'"></paper-icon-button>
I have got help from the #meteor community. 我从#meteor社区获得了帮助。 The answers came from use users: "pchoo" and "rpitt".
答案来自使用用户:“ pchoo”和“ rpitt”。 Many thanks for the answer:
非常感谢您的回答:
{{with currentUser}}
<paper-icon-button icon="perm-identity" onclick="location.href='{{pathFor 'CompanyUpdate' _id=id}}'"></paper-icon-button>
{{/with}}
The above solved my issue. 以上解决了我的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.