I suppose the _id
in your route comes from a collection, you need to pass route.path
the document the route is based on.
Router.route("/client/:_id/edit",{
name:"edit",
data:function(){
return MyCollection.findOne(this.params._id);
}
});
<template name="edit">
{{myHelper}}
{{pathFor route="edit"}}
</template>
Template.edit.helpers({
myHelper:function(){
return Router.current().route.path(this);
}
});
I suggest you use the default pathFor
helper for rendering an URL in the app.
https://github.com/EventedMind/iron-router/blob/devel/Guide.md#pathfor
This helper is using the current data context (in this case MyCollection.findOne(this.params._id)
) to extract route parameters.
But you can also use the path method from the route, which takes the document you want to generate the path for as first argument.