Im trying to implement an user update page in my Meteor app. My 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
. 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.
I am still learning meteor and would like someone to explain what is missing or doing wrong.
userId
in your template in null. Try using the default {{currentUser}}
template which calls 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. The answers came from use users: "pchoo" and "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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.