Skip to content

Commit

Permalink
Update documentation for currentRoute
Browse files Browse the repository at this point in the history
(cherry picked from commit de46720)
  • Loading branch information
sdebarros authored and rwjblue committed Jun 17, 2019
1 parent 925bee3 commit a2edef0
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions packages/@ember/-internals/routing/lib/services/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ RouterService.reopen(Evented, {
the application, '/' by default.
This prefix is assumed on all routes defined on this app.
IF you change the `rootURL` in your environment configuration
If you change the `rootURL` in your environment configuration
like so:
```config/environment.js
Expand All @@ -463,10 +463,28 @@ RouterService.reopen(Evented, {
rootURL: readOnly('_router.rootURL'),

/**
A `RouteInfo` that represents the current leaf route.
It is guaranteed to change whenever a route transition
happens (even when that transition only changes parameters
and doesn't change the active route)
The `currentRoute` property contains metadata about the current leaf route.
It returns a `RouteInfo` object that has information like the route name,
params, query params and more.
See [RouteInfo](/ember/release/classes/RouteInfo) for more info.
This property is guaranteed to change whenever a route transition
happens (even when that transition only changes parameters
and doesn't change the active route).
Usage example:
```app/components/header.js
import Component from '@ember/component';
import { inject as service } from '@ember/service';
import { computed } from '@ember/object';
export default Component.extend({
router: service(),
isChildRoute: computed.notEmpty('router.currentRoute.child')
});
```
@property currentRoute
@type RouteInfo
Expand Down

0 comments on commit a2edef0

Please sign in to comment.