Skip to content

Commit 3084927

Browse files
sdebarrosRobert Jackson
authored andcommitted
Update documentation for currentRoute
(cherry picked from commit de46720)
1 parent 487721e commit 3084927

1 file changed

Lines changed: 23 additions & 5 deletions

File tree

  • packages/@ember/-internals/routing/lib/services

packages/@ember/-internals/routing/lib/services/router.ts

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ RouterService.reopen(Evented, {
439439
the application, '/' by default.
440440
This prefix is assumed on all routes defined on this app.
441441
442-
IF you change the `rootURL` in your environment configuration
442+
If you change the `rootURL` in your environment configuration
443443
like so:
444444
445445
```config/environment.js
@@ -464,10 +464,28 @@ RouterService.reopen(Evented, {
464464
rootURL: readOnly('_router.rootURL'),
465465

466466
/**
467-
A `RouteInfo` that represents the current leaf route.
468-
It is guaranteed to change whenever a route transition
469-
happens (even when that transition only changes parameters
470-
and doesn't change the active route)
467+
The `currentRoute` property contains metadata about the current leaf route.
468+
It returns a `RouteInfo` object that has information like the route name,
469+
params, query params and more.
470+
471+
See [RouteInfo](/ember/release/classes/RouteInfo) for more info.
472+
473+
This property is guaranteed to change whenever a route transition
474+
happens (even when that transition only changes parameters
475+
and doesn't change the active route).
476+
477+
Usage example:
478+
```app/components/header.js
479+
import Component from '@ember/component';
480+
import { inject as service } from '@ember/service';
481+
import { computed } from '@ember/object';
482+
483+
export default Component.extend({
484+
router: service(),
485+
486+
isChildRoute: computed.notEmpty('router.currentRoute.child')
487+
});
488+
```
471489
472490
@property currentRoute
473491
@type RouteInfo

0 commit comments

Comments
 (0)