ember-source 4.3.0-alpha.4 → 4.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -2
- package/build-metadata.json +3 -3
- package/dist/dependencies/router_js.js +66 -31
- package/dist/ember-template-compiler.js +16 -13
- package/dist/ember-template-compiler.map +1 -1
- package/dist/ember-testing.js +1 -1
- package/dist/ember-testing.map +1 -1
- package/dist/ember.debug.js +685 -1223
- package/dist/ember.debug.map +1 -1
- package/dist/header/license.js +1 -1
- package/dist/packages/@ember/-internals/container/index.js +15 -20
- package/dist/packages/@ember/-internals/glimmer/index.js +60 -45
- package/dist/packages/@ember/-internals/meta/lib/meta.js +8 -9
- package/dist/packages/@ember/-internals/metal/index.js +44 -45
- package/dist/packages/@ember/-internals/routing/lib/ext/controller.js +10 -8
- package/dist/packages/@ember/-internals/routing/lib/services/router.js +165 -197
- package/dist/packages/@ember/-internals/routing/lib/system/route-info.js +2 -2
- package/dist/packages/@ember/-internals/routing/lib/system/route.js +96 -375
- package/dist/packages/@ember/-internals/routing/lib/system/router.js +62 -35
- package/dist/packages/@ember/-internals/routing/lib/utils.js +31 -20
- package/dist/packages/@ember/-internals/runtime/lib/mixins/action_handler.js +32 -32
- package/dist/packages/@ember/-internals/utils/index.js +2 -0
- package/dist/packages/@ember/-internals/views/lib/system/utils.js +1 -0
- package/dist/packages/@ember/canary-features/index.js +2 -2
- package/dist/packages/@ember/controller/index.js +3 -54
- package/dist/packages/@ember/instrumentation/index.js +9 -13
- package/dist/packages/@ember/routing/router-service.js +1 -0
- package/dist/packages/@ember/service/index.js +6 -73
- package/dist/packages/ember/version.js +1 -1
- package/docs/data.json +411 -343
- package/package.json +5 -8
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __decorate = this && this.__decorate || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length,
|
|
3
|
+
r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc,
|
|
4
|
+
d;
|
|
5
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
import { getOwner } from '@ember/-internals/owner';
|
|
2
10
|
import { Evented } from '@ember/-internals/runtime';
|
|
3
11
|
import { symbol } from '@ember/-internals/utils';
|
|
@@ -15,40 +23,106 @@ function cleanURL(url, rootURL) {
|
|
|
15
23
|
|
|
16
24
|
return url.substr(rootURL.length, url.length);
|
|
17
25
|
}
|
|
18
|
-
/**
|
|
19
|
-
The Router service is the public API that provides access to the router.
|
|
20
|
-
|
|
21
|
-
The immediate benefit of the Router service is that you can inject it into components,
|
|
22
|
-
giving them a friendly way to initiate transitions and ask questions about the current
|
|
23
|
-
global router state.
|
|
24
|
-
|
|
25
|
-
In this example, the Router service is injected into a component to initiate a transition
|
|
26
|
-
to a dedicated route:
|
|
27
|
-
|
|
28
|
-
```app/components/example.js
|
|
29
|
-
import Component from '@glimmer/component';
|
|
30
|
-
import { action } from '@ember/object';
|
|
31
|
-
import { service } from '@ember/service';
|
|
32
26
|
|
|
33
|
-
|
|
34
|
-
|
|
27
|
+
class RouterService extends Service.extend(Evented) {
|
|
28
|
+
constructor() {
|
|
29
|
+
super(...arguments);
|
|
30
|
+
/**
|
|
31
|
+
The `routeWillChange` event is fired at the beginning of any
|
|
32
|
+
attempted transition with a `Transition` object as the sole
|
|
33
|
+
argument. This action can be used for aborting, redirecting,
|
|
34
|
+
or decorating the transition from the currently active routes.
|
|
35
|
+
A good example is preventing navigation when a form is
|
|
36
|
+
half-filled out:
|
|
37
|
+
```app/routes/contact-form.js
|
|
38
|
+
import Route from '@ember/routing';
|
|
39
|
+
import { service } from '@ember/service';
|
|
40
|
+
export default class extends Route {
|
|
41
|
+
@service router;
|
|
42
|
+
constructor() {
|
|
43
|
+
super(...arguments);
|
|
44
|
+
this.router.on('routeWillChange', (transition) => {
|
|
45
|
+
if (!transition.to.find(route => route.name === this.routeName)) {
|
|
46
|
+
alert("Please save or cancel your changes.");
|
|
47
|
+
transition.abort();
|
|
48
|
+
}
|
|
49
|
+
})
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
```
|
|
53
|
+
The `routeWillChange` event fires whenever a new route is chosen as the desired target of a transition. This includes `transitionTo`, `replaceWith`, all redirection for any reason including error handling, and abort. Aborting implies changing the desired target back to where you already were. Once a transition has completed, `routeDidChange` fires.
|
|
54
|
+
@event routeWillChange
|
|
55
|
+
@param {Transition} transition
|
|
56
|
+
@public
|
|
57
|
+
*/
|
|
35
58
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
59
|
+
/**
|
|
60
|
+
The `routeDidChange` event only fires once a transition has settled.
|
|
61
|
+
This includes aborts and error substates. Like the `routeWillChange` event
|
|
62
|
+
it receives a Transition as the sole argument.
|
|
63
|
+
A good example is sending some analytics when the route has transitioned:
|
|
64
|
+
```app/routes/contact-form.js
|
|
65
|
+
import Route from '@ember/routing';
|
|
66
|
+
import { service } from '@ember/service';
|
|
67
|
+
export default class extends Route {
|
|
68
|
+
@service router;
|
|
69
|
+
constructor() {
|
|
70
|
+
super(...arguments);
|
|
71
|
+
this.router.on('routeDidChange', (transition) => {
|
|
72
|
+
ga.send('pageView', {
|
|
73
|
+
current: transition.to.name,
|
|
74
|
+
from: transition.from.name
|
|
75
|
+
});
|
|
76
|
+
})
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
`routeDidChange` will be called after any `Route`'s
|
|
81
|
+
[didTransition](/ember/release/classes/Route/events/didTransition?anchor=didTransition)
|
|
82
|
+
action has been fired.
|
|
83
|
+
The updates of properties
|
|
84
|
+
[currentURL](/ember/release/classes/RouterService/properties/currentURL?anchor=currentURL),
|
|
85
|
+
[currentRouteName](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRouteName)
|
|
86
|
+
and
|
|
87
|
+
[currentRoute](/ember/release/classes/RouterService/properties/currentURL?anchor=currentRoute)
|
|
88
|
+
are completed at the time `routeDidChange` is called.
|
|
89
|
+
@event routeDidChange
|
|
90
|
+
@param {Transition} transition
|
|
91
|
+
@public
|
|
92
|
+
*/
|
|
93
|
+
// Canary features
|
|
42
94
|
|
|
43
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Refreshes all currently active routes, doing a full transition.
|
|
97
|
+
* If a route name is provided and refers to a currently active route,
|
|
98
|
+
* it will refresh only that route and its descendents.
|
|
99
|
+
* Returns a promise that will be resolved once the refresh is complete.
|
|
100
|
+
* All resetController, beforeModel, model, afterModel, redirect, and setupController
|
|
101
|
+
* hooks will be called again. You will get new data from the model hook.
|
|
102
|
+
*
|
|
103
|
+
* @method refresh
|
|
104
|
+
* @param {String} [routeName] the route to refresh (along with all child routes)
|
|
105
|
+
* @return Transition
|
|
106
|
+
* @category EMBER_ROUTING_ROUTER_SERVICE_REFRESH
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
44
109
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
110
|
+
this.refresh = true
|
|
111
|
+
/* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
|
|
112
|
+
? function (pivotRouteName) {
|
|
113
|
+
if (!pivotRouteName) {
|
|
114
|
+
return this._router._routerMicrolib.refresh();
|
|
115
|
+
}
|
|
49
116
|
|
|
117
|
+
assert(`The route "${pivotRouteName}" was not found`, this._router.hasRoute(pivotRouteName));
|
|
118
|
+
assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
|
|
119
|
+
let owner = getOwner(this);
|
|
120
|
+
assert('RouterService is unexpectedly missing an owner', owner);
|
|
121
|
+
let pivotRoute = owner.lookup(`route:${pivotRouteName}`);
|
|
122
|
+
return this._router._routerMicrolib.refresh(pivotRoute);
|
|
123
|
+
} : undefined;
|
|
124
|
+
}
|
|
50
125
|
|
|
51
|
-
export default class RouterService extends Service {
|
|
52
126
|
get _router() {
|
|
53
127
|
let router = this[ROUTER];
|
|
54
128
|
|
|
@@ -63,9 +137,48 @@ export default class RouterService extends Service {
|
|
|
63
137
|
}
|
|
64
138
|
|
|
65
139
|
willDestroy() {
|
|
66
|
-
super.willDestroy(
|
|
140
|
+
super.willDestroy();
|
|
67
141
|
this[ROUTER] = null;
|
|
68
142
|
}
|
|
143
|
+
/**
|
|
144
|
+
Transition the application into another route. The route may
|
|
145
|
+
be either a single route or route path:
|
|
146
|
+
Calling `transitionTo` from the Router service will cause default query parameter values to be included in the URL.
|
|
147
|
+
This behavior is different from calling `transitionTo` on a route or `transitionToRoute` on a controller.
|
|
148
|
+
See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info.
|
|
149
|
+
In the following example we use the Router service to navigate to a route with a
|
|
150
|
+
specific model from a Component in the first action, and in the second we trigger
|
|
151
|
+
a query-params only transition.
|
|
152
|
+
```app/components/example.js
|
|
153
|
+
import Component from '@glimmer/component';
|
|
154
|
+
import { action } from '@ember/object';
|
|
155
|
+
import { service } from '@ember/service';
|
|
156
|
+
export default class extends Component {
|
|
157
|
+
@service router;
|
|
158
|
+
@action
|
|
159
|
+
goToComments(post) {
|
|
160
|
+
this.router.transitionTo('comments', post);
|
|
161
|
+
}
|
|
162
|
+
@action
|
|
163
|
+
fetchMoreComments(latestComment) {
|
|
164
|
+
this.router.transitionTo({
|
|
165
|
+
queryParams: { commentsAfter: latestComment }
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
```
|
|
170
|
+
@method transitionTo
|
|
171
|
+
@param {String} [routeNameOrUrl] the name of the route or a URL
|
|
172
|
+
@param {...Object} [models] the model(s) or identifier(s) to be used while
|
|
173
|
+
transitioning to the route.
|
|
174
|
+
@param {Object} [options] optional hash with a queryParams property
|
|
175
|
+
containing a mapping of query parameters. May be supplied as the only
|
|
176
|
+
parameter to trigger a query-parameter-only transition.
|
|
177
|
+
@return {Transition} the transition object associated with this
|
|
178
|
+
attempted transition
|
|
179
|
+
@public
|
|
180
|
+
*/
|
|
181
|
+
|
|
69
182
|
|
|
70
183
|
transitionTo(...args) {
|
|
71
184
|
if (resemblesURL(args[0])) {
|
|
@@ -82,7 +195,6 @@ export default class RouterService extends Service {
|
|
|
82
195
|
|
|
83
196
|
let transition = this._router._doTransition(routeName, models, queryParams, true);
|
|
84
197
|
|
|
85
|
-
transition['_keepDefaultQueryParamValues'] = true;
|
|
86
198
|
return transition;
|
|
87
199
|
}
|
|
88
200
|
/**
|
|
@@ -91,7 +203,6 @@ export default class RouterService extends Service {
|
|
|
91
203
|
When the user clicks the "back" button in the browser, there will be fewer steps.
|
|
92
204
|
This is most commonly used to manage redirects in a way that does not cause confusing additions
|
|
93
205
|
to the user's browsing history.
|
|
94
|
-
See [replaceWith](/ember/release/classes/Route/methods/replaceWith?anchor=replaceWith) for more info.
|
|
95
206
|
Calling `replaceWith` from the Router service will cause default query parameter values to be included in the URL.
|
|
96
207
|
This behavior is different from calling `replaceWith` on a route.
|
|
97
208
|
See the [Router Service RFC](https://github.com/emberjs/rfcs/blob/master/text/0095-router-service.md#query-parameter-semantics) for more info.
|
|
@@ -118,8 +229,8 @@ export default class RouterService extends Service {
|
|
|
118
229
|
*/
|
|
119
230
|
|
|
120
231
|
|
|
121
|
-
replaceWith() {
|
|
122
|
-
return this.transitionTo(...
|
|
232
|
+
replaceWith(...args) {
|
|
233
|
+
return this.transitionTo(...args).method('replace');
|
|
123
234
|
}
|
|
124
235
|
/**
|
|
125
236
|
Generate a URL based on the supplied route name and optionally a model. The
|
|
@@ -172,8 +283,7 @@ export default class RouterService extends Service {
|
|
|
172
283
|
```
|
|
173
284
|
@method urlFor
|
|
174
285
|
@param {String} routeName the name of the route
|
|
175
|
-
@param {...Object} models the model(s)
|
|
176
|
-
transitioning to the route.
|
|
286
|
+
@param {...Object} models the model(s) for the route.
|
|
177
287
|
@param {Object} [options] optional hash with a queryParams property
|
|
178
288
|
containing a mapping of query parameters
|
|
179
289
|
@return {String} the string representing the generated URL
|
|
@@ -255,19 +365,26 @@ export default class RouterService extends Service {
|
|
|
255
365
|
let hasQueryParams = Object.keys(queryParams).length > 0;
|
|
256
366
|
|
|
257
367
|
if (hasQueryParams) {
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
this._router._prepareQueryParams( // UNSAFE: casting `routeName as string` here encodes the existing
|
|
368
|
+
// UNSAFE: casting `routeName as string` here encodes the existing
|
|
261
369
|
// assumption but may be wrong: `extractRouteArgs` correctly returns it
|
|
262
370
|
// as `string | undefined`. There may be bugs if `_prepareQueryParams`
|
|
263
371
|
// does not correctly account for `undefined` values for `routeName`.
|
|
264
372
|
// Spoilers: under the hood this currently uses router.js APIs which
|
|
265
373
|
// *do not* account for this being `undefined`.
|
|
266
|
-
|
|
374
|
+
let targetRouteName = routeName;
|
|
375
|
+
queryParams = Object.assign({}, queryParams);
|
|
376
|
+
|
|
377
|
+
this._router._prepareQueryParams(targetRouteName, models, queryParams, true
|
|
267
378
|
/* fromRouterService */
|
|
268
379
|
);
|
|
269
380
|
|
|
270
|
-
|
|
381
|
+
let currentQueryParams = Object.assign({}, routerMicrolib.state.queryParams);
|
|
382
|
+
|
|
383
|
+
this._router._prepareQueryParams(targetRouteName, models, currentQueryParams, true
|
|
384
|
+
/* fromRouterService */
|
|
385
|
+
);
|
|
386
|
+
|
|
387
|
+
return shallowEqual(queryParams, currentQueryParams);
|
|
271
388
|
}
|
|
272
389
|
|
|
273
390
|
return true;
|
|
@@ -294,6 +411,7 @@ export default class RouterService extends Service {
|
|
|
294
411
|
```
|
|
295
412
|
@method recognize
|
|
296
413
|
@param {String} url
|
|
414
|
+
@return {RouteInfo | null}
|
|
297
415
|
@public
|
|
298
416
|
*/
|
|
299
417
|
|
|
@@ -314,6 +432,7 @@ export default class RouterService extends Service {
|
|
|
314
432
|
the browser including the app's `rootURL`.
|
|
315
433
|
@method recognizeAndLoad
|
|
316
434
|
@param {String} url
|
|
435
|
+
@return {RouteInfo}
|
|
317
436
|
@public
|
|
318
437
|
*/
|
|
319
438
|
|
|
@@ -329,165 +448,14 @@ export default class RouterService extends Service {
|
|
|
329
448
|
|
|
330
449
|
}
|
|
331
450
|
|
|
332
|
-
|
|
333
|
-
/* EMBER_ROUTING_ROUTER_SERVICE_REFRESH */
|
|
334
|
-
) {
|
|
335
|
-
RouterService.reopen({
|
|
336
|
-
/**
|
|
337
|
-
* Refreshes all currently active routes, doing a full transition.
|
|
338
|
-
* If a route name is provided and refers to a currently active route,
|
|
339
|
-
* it will refresh only that route and its descendents.
|
|
340
|
-
* Returns a promise that will be resolved once the refresh is complete.
|
|
341
|
-
* All resetController, beforeModel, model, afterModel, redirect, and setupController
|
|
342
|
-
* hooks will be called again. You will get new data from the model hook.
|
|
343
|
-
*
|
|
344
|
-
* @method refresh
|
|
345
|
-
* @param {String} [routeName] the route to refresh (along with all child routes)
|
|
346
|
-
* @return Transition
|
|
347
|
-
* @category EMBER_ROUTING_ROUTER_SERVICE_REFRESH
|
|
348
|
-
* @public
|
|
349
|
-
*/
|
|
350
|
-
refresh(pivotRouteName) {
|
|
351
|
-
if (!pivotRouteName) {
|
|
352
|
-
return this._router._routerMicrolib.refresh();
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
assert(`The route "${pivotRouteName}" was not found`, this._router.hasRoute(pivotRouteName));
|
|
356
|
-
assert(`The route "${pivotRouteName}" is currently not active`, this.isActive(pivotRouteName));
|
|
357
|
-
let owner = getOwner(this);
|
|
358
|
-
assert('RouterService is unexpectedly missing an owner', owner);
|
|
359
|
-
let pivotRoute = owner.lookup(`route:${pivotRouteName}`);
|
|
360
|
-
return this._router._routerMicrolib.refresh(pivotRoute);
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
});
|
|
364
|
-
}
|
|
451
|
+
__decorate([readOnly('_router.currentRouteName')], RouterService.prototype, "currentRouteName", void 0);
|
|
365
452
|
|
|
366
|
-
RouterService.
|
|
367
|
-
/**
|
|
368
|
-
Name of the current route.
|
|
369
|
-
This property represents the logical name of the route,
|
|
370
|
-
which is comma separated.
|
|
371
|
-
For the following router:
|
|
372
|
-
```app/router.js
|
|
373
|
-
Router.map(function() {
|
|
374
|
-
this.route('about');
|
|
375
|
-
this.route('blog', function () {
|
|
376
|
-
this.route('post', { path: ':post_id' });
|
|
377
|
-
});
|
|
378
|
-
});
|
|
379
|
-
```
|
|
380
|
-
It will return:
|
|
381
|
-
* `index` when you visit `/`
|
|
382
|
-
* `about` when you visit `/about`
|
|
383
|
-
* `blog.index` when you visit `/blog`
|
|
384
|
-
* `blog.post` when you visit `/blog/some-post-id`
|
|
385
|
-
@property currentRouteName
|
|
386
|
-
@type String
|
|
387
|
-
@public
|
|
388
|
-
*/
|
|
389
|
-
currentRouteName: readOnly('_router.currentRouteName'),
|
|
453
|
+
__decorate([readOnly('_router.currentURL')], RouterService.prototype, "currentURL", void 0);
|
|
390
454
|
|
|
391
|
-
|
|
392
|
-
Current URL for the application.
|
|
393
|
-
This property represents the URL path for this route.
|
|
394
|
-
For the following router:
|
|
395
|
-
```app/router.js
|
|
396
|
-
Router.map(function() {
|
|
397
|
-
this.route('about');
|
|
398
|
-
this.route('blog', function () {
|
|
399
|
-
this.route('post', { path: ':post_id' });
|
|
400
|
-
});
|
|
401
|
-
});
|
|
402
|
-
```
|
|
403
|
-
It will return:
|
|
404
|
-
* `/` when you visit `/`
|
|
405
|
-
* `/about` when you visit `/about`
|
|
406
|
-
* `/blog` when you visit `/blog`
|
|
407
|
-
* `/blog/some-post-id` when you visit `/blog/some-post-id`
|
|
408
|
-
@property currentURL
|
|
409
|
-
@type String
|
|
410
|
-
@public
|
|
411
|
-
*/
|
|
412
|
-
currentURL: readOnly('_router.currentURL'),
|
|
455
|
+
__decorate([readOnly('_router.location')], RouterService.prototype, "location", void 0);
|
|
413
456
|
|
|
414
|
-
|
|
415
|
-
The `location` property returns what implementation of the `location` API
|
|
416
|
-
your application is using, which determines what type of URL is being used.
|
|
417
|
-
See [Location](/ember/release/classes/Location) for more information.
|
|
418
|
-
To force a particular `location` API implementation to be used in your
|
|
419
|
-
application you can set a location type on your `config/environment`.
|
|
420
|
-
For example, to set the `history` type:
|
|
421
|
-
```config/environment.js
|
|
422
|
-
'use strict';
|
|
423
|
-
module.exports = function(environment) {
|
|
424
|
-
let ENV = {
|
|
425
|
-
modulePrefix: 'router-service',
|
|
426
|
-
environment,
|
|
427
|
-
rootURL: '/',
|
|
428
|
-
locationType: 'history',
|
|
429
|
-
...
|
|
430
|
-
}
|
|
431
|
-
}
|
|
432
|
-
```
|
|
433
|
-
The following location types are available by default:
|
|
434
|
-
`auto`, `hash`, `history`, `none`.
|
|
435
|
-
See [HashLocation](/ember/release/classes/HashLocation).
|
|
436
|
-
See [HistoryLocation](/ember/release/classes/HistoryLocation).
|
|
437
|
-
See [NoneLocation](/ember/release/classes/NoneLocation).
|
|
438
|
-
See [AutoLocation](/ember/release/classes/AutoLocation).
|
|
439
|
-
@property location
|
|
440
|
-
@default 'hash'
|
|
441
|
-
@see {Location}
|
|
442
|
-
@public
|
|
443
|
-
*/
|
|
444
|
-
location: readOnly('_router.location'),
|
|
457
|
+
__decorate([readOnly('_router.rootURL')], RouterService.prototype, "rootURL", void 0);
|
|
445
458
|
|
|
446
|
-
|
|
447
|
-
The `rootURL` property represents the URL of the root of
|
|
448
|
-
the application, '/' by default.
|
|
449
|
-
This prefix is assumed on all routes defined on this app.
|
|
450
|
-
If you change the `rootURL` in your environment configuration
|
|
451
|
-
like so:
|
|
452
|
-
```config/environment.js
|
|
453
|
-
'use strict';
|
|
454
|
-
module.exports = function(environment) {
|
|
455
|
-
let ENV = {
|
|
456
|
-
modulePrefix: 'router-service',
|
|
457
|
-
environment,
|
|
458
|
-
rootURL: '/my-root',
|
|
459
|
-
…
|
|
460
|
-
}
|
|
461
|
-
]
|
|
462
|
-
```
|
|
463
|
-
This property will return `/my-root`.
|
|
464
|
-
@property rootURL
|
|
465
|
-
@default '/'
|
|
466
|
-
@public
|
|
467
|
-
*/
|
|
468
|
-
rootURL: readOnly('_router.rootURL'),
|
|
459
|
+
__decorate([readOnly('_router.currentRoute')], RouterService.prototype, "currentRoute", void 0);
|
|
469
460
|
|
|
470
|
-
|
|
471
|
-
The `currentRoute` property contains metadata about the current leaf route.
|
|
472
|
-
It returns a `RouteInfo` object that has information like the route name,
|
|
473
|
-
params, query params and more.
|
|
474
|
-
See [RouteInfo](/ember/release/classes/RouteInfo) for more info.
|
|
475
|
-
This property is guaranteed to change whenever a route transition
|
|
476
|
-
happens (even when that transition only changes parameters
|
|
477
|
-
and doesn't change the active route).
|
|
478
|
-
Usage example:
|
|
479
|
-
```app/components/header.js
|
|
480
|
-
import Component from '@glimmer/component';
|
|
481
|
-
import { service } from '@ember/service';
|
|
482
|
-
import { notEmpty } from '@ember/object/computed';
|
|
483
|
-
export default class extends Component {
|
|
484
|
-
@service router;
|
|
485
|
-
@notEmpty('router.currentRoute.child') isChildRoute;
|
|
486
|
-
});
|
|
487
|
-
```
|
|
488
|
-
@property currentRoute
|
|
489
|
-
@type RouteInfo
|
|
490
|
-
@public
|
|
491
|
-
*/
|
|
492
|
-
currentRoute: readOnly('_router.currentRoute')
|
|
493
|
-
});
|
|
461
|
+
export { RouterService as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
/**
|
|
3
3
|
A `RouteInfoWithAttributes` is an object that contains
|
|
4
4
|
metadata, including the resolved value from the routes
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
/**
|
|
56
56
|
This is the resolved return value from the
|
|
57
57
|
route's model hook.
|
|
58
|
-
@property {Object|Array|String} attributes
|
|
58
|
+
@property {Object|Array|String|undefined} attributes
|
|
59
59
|
@public
|
|
60
60
|
*/
|
|
61
61
|
|