Meteor Iron Router does not get Current Path from Route
Asked Answered
R

1

2

In a Template Helper I get the current path from Iron.Router (iron:router) as follows:

Router.current().route.path(this);

This works fine, unless the route path does contain parameters (e.g. /client/:_id/edit). In that case the path() function returns null.

How do I get the current path within a Template Helper, when the route contains parameters?

There are posts around covering the issue but the solution mentioned there seem not to fit.

I'm using Meteor 1.1.5 with iron:router1.0.7

Revolution answered 20/4, 2015 at 6:57 Comment(0)
R
5

According to this iron-router/issues/289 there are problems when the path contains parameters. The suggestion to use Iron.Location.get().path This works well for me.

Revolution answered 20/4, 2015 at 9:21 Comment(1)
Fantastic, I was able to use this to set classes to active based on the URL. Thank you!Tiresome

© 2022 - 2024 — McMap. All rights reserved.