JS 'linkTo' API



I’m created a re-usable grid component. The grid component needs to be able to render links - internal to the app or external. The simplest way to do this would be for the grid component to look for an href property in the provided data, letting the parent controller construct the href however it wants to.


The parent component can’t construct the href and pass it through because Ember’s link-to functionality is only available as a HandleBars helper.


A new API (example for demonstration purposes only):

// Returns '/group/123/person/456/'
Ember.Location.linkTo('group.person', {group: 123, person: 456})

This is conceptually similar to Django’s reverse() method.

I’m pretty new to Ember - I’d love to hear feedback on other ways to address this problem. Thanks!


This sounds like what you are looking for:


jsonmit, that’s exactly what I’m looking for. Thank you!

I can’t find any reference to router.generate() in the API docs - am I missing it, or is this an internal, undocumented feature?


It’s not annotated in the source, so it’s likely all of the above.