vendredi 22 mai 2015

Adding and retrieving metadata from Ember routes

For reporting purposes, I want to associate some metadata with an Ember route, and would prefer to do it as follows:

this.route('list', { path: '/list', description: 'Master List' });

then access this description property from places like the route itself, or from elsewhere, such as the didTransition hook on the application router. I've reviewed the source for Router and Route and cannot say I really understand it, certainly not well enough to understand how to retrieve custom properties specified in this way. I see there is an object called DSL, which is apparently the this of the this.route specified in the map method on Router, but cannot see how to get from here to there. From within a subclass of Ember.Route, I see properties called this.router, and this.router.router, but am unclear on what these point to.

Or, the following would also work if that allowed me to do what I wanted:

this.route('list', { path: '/list' }, function() {
    this.description = "Master List";
});

Can I associate custom properties with a route specified in Router#map, and if so how?




Aucun commentaire:

Enregistrer un commentaire