New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Get current URL #289
Comments
|
Simple enough. Thanks. |
But how to pass Router.current().path to the template? Template.navbar.currentPath = function () {
return Router.current().path;
}; does not work because Router is null. It is available later. That template binding is working BEFORE the Router object is available. How to sync it? I only found an ugly workaround like that: Template.navbar.currentPath = function () {
return Router && Router.current() && Router.current().path;
}; |
Hi, this |
hi @rubencodes try: Router.current().route.getName() It will give you the name of route :) Hope this helps. |
or you can simply using
it will have same result with old iron router
|
It depends when you use it, if you call However if you use As @rubencodes noticed there are some inconsistencies with |
Awesome, I am looking for this solution in iron router doc, and cannot find about this
So I change all of my current code to window.location.path. Thanks for the awesome answer |
According to my answer at http://stackoverflow.com/questions/21091868/meteor-breadcrumb/27426970#27426970 you can do: |
|
What about server code? How can I get current path and params? :/ |
Hi! There is any way to get the actual URL in a template? Or I have to create a custom helper for that? |
I have not value
I had get current url this command.
|
Use This : |
As it is not consistent between localhost and my server, this is my solution: getUrl = function() {
let url = Router.current().url;
if(url.slice(0, 4) !== 'http')
url = Meteor.absoluteUrl() + url.slice(1, url.length);
return url;
}; |
Hi,
I was wondering if it is possible to get the current (parametrized) URL.
Using : Router.current().route.name is a bit too complicated for what I would like to do.
Thanks
The text was updated successfully, but these errors were encountered: