Skip to content

Commit

Permalink
add buildRouteInfoMetadata docs
Browse files Browse the repository at this point in the history
  • Loading branch information
chadhietala committed Dec 10, 2018
1 parent c0accdc commit 7ee84aa
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions packages/@ember/-internals/routing/lib/system/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2559,6 +2559,41 @@ if (EMBER_ROUTING_ROUTER_SERVICE && ROUTER_EVENTS) {

if (EMBER_ROUTING_BUILD_ROUTEINFO_METADATA) {
Route.reopen({
/**
Allows you to produce custom metadata for the route.
The return value of this method will be attatched to
its corresponding RouteInfoWithAttributes obejct.
Example
```app/routes/posts/index.js
import Route from '@ember/routing/route';
export default Route.extend({
buildRouteInfoMetadata() {
return { title: 'Posts Page' }
}
});
```
```app/routes/application.js
import Route from '@ember/routing/route';
import { inject as service } from '@ember/service';
export default Route.extend({
router: service('router'),
init() {
this._super(...arguments);
this.router.on('routeDidChange', transition => {
document.title = transition.to.metadata.title;
// would update document's title to "Posts Page"
});
}
});
```
@return any
@category ember-routing-build-routeinfo-metadata
*/
buildRouteInfoMetadata() {},
});
}
Expand Down

0 comments on commit 7ee84aa

Please sign in to comment.