Skip to content
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

Can not use router service in route #16088

Closed
bobisjan opened this issue Jan 8, 2018 · 3 comments
Closed

Can not use router service in route #16088

bobisjan opened this issue Jan 8, 2018 · 3 comments
Assignees

Comments

@bobisjan
Copy link
Contributor

bobisjan commented Jan 8, 2018

Hi,

when I inject RouterService into some route, this property is replaced by router:main.

import Route from '@ember/routing';
import { inject } from '@ember/service';

export default Route.extend({
  router: inject()
});

API does not expose router property (public or private), I can use named inject like routing: inject('router'), but it seems to me, that this should work out of box?

The intent is to use ember-cli-meta-tags and urlFor() to generate URL for rel meta tags and the router:main does not have this method available.

Thanks

@locks
Copy link
Contributor

locks commented Jan 9, 2018

This is because router is already a private property of the Route class.
Hm, not sure what specifically is going on here… Can you provide an ember-twiddle.com reproduction?

@locks locks self-assigned this Jan 9, 2018
@bobisjan
Copy link
Contributor Author

bobisjan commented Jan 9, 2018

I see that router is used in route's codebase, but I'm not sure if the injection should work (as other service injections) or router should be marked as private in API and maybe throw error when someone tries to inject router service into route using router: inject()?

Here is a basic Twiddle, see console with logged error, router is not a router service instance.

@cibernox
Copy link
Contributor

cibernox commented Mar 2, 2018

FWIW, since Route#router is private API, this seems a bug to me. That private API should be _router or something even more private that doesn't preclude users to inject the router service with the very reasonable name of "router".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants