@angular-wave/angular.ts 0.0.27 → 0.0.29
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/README.md +1 -2
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/e2e/unit.spec.ts +2 -1
- package/index.html +6 -6
- package/package.json +1 -1
- package/src/core/pubsub.js +329 -0
- package/src/router/common/trace.js +6 -6
- package/src/router/directives/state-directives.js +74 -74
- package/src/router/directives/view-directive.js +21 -21
- package/src/router/hooks/core-resolvables.js +12 -11
- package/src/router/hooks/ignored-transition.js +1 -1
- package/src/router/hooks/lazy-load.js +40 -41
- package/src/router/hooks/redirect-to.js +32 -29
- package/src/router/hooks/update-globals.js +1 -1
- package/src/router/hooks/url.js +33 -24
- package/src/router/hooks/views.js +21 -20
- package/src/router/index.js +12 -12
- package/src/router/injectables.js +3 -3
- package/src/router/params/param-factory.js +17 -0
- package/src/router/router.js +75 -10
- package/src/router/services.js +4 -8
- package/src/router/state/state-builder.js +1 -0
- package/src/router/state/state-queue-manager.js +5 -4
- package/src/router/state/state-registry.js +63 -7
- package/src/router/state/state-service.js +47 -51
- package/src/router/state/views.js +4 -4
- package/src/router/state-filters.js +0 -2
- package/src/router/state-provider.js +0 -2
- package/src/router/template-factory.js +4 -4
- package/src/router/transition/hook-builder.js +2 -2
- package/src/router/transition/transition-hook.js +2 -1
- package/src/router/transition/transition-service.js +11 -18
- package/src/router/transition/transition.js +28 -25
- package/src/router/url/url-config.js +1 -49
- package/src/router/url/url-matcher-factory.js +10 -51
- package/src/router/url/url-router.js +31 -17
- package/src/router/url/url-rule.js +9 -13
- package/src/router/url/url-rules.js +3 -3
- package/src/router/url/url-service.js +22 -18
- package/src/router/view/view.js +67 -67
- package/src/services/browser.js +1 -5
- package/src/shared/hof.js +1 -1
- package/test/angular.spec.js +1 -0
- package/test/aria/aria.spec.js +2 -1
- package/test/core/pubsub.spec.js +387 -0
- package/test/directive/bind.spec.js +2 -1
- package/test/directive/boolean.spec.js +4 -2
- package/test/directive/change.spec.js +1 -1
- package/test/directive/class.spec.js +1 -0
- package/test/directive/click.spec.js +2 -1
- package/test/directive/cloak.spec.js +1 -2
- package/test/directive/{constoller.spec.js → controller.spec.js} +1 -0
- package/test/directive/element-style.spec.js +1 -0
- package/test/directive/event.spec.js +1 -1
- package/test/directive/href.spec.js +2 -1
- package/test/directive/init.spec.js +1 -0
- package/test/directive/input.spec.js +200 -285
- package/test/directive/list.spec.js +2 -1
- package/test/directive/model.spec.js +1 -0
- package/test/directive/non-bindable.spec.js +2 -1
- package/test/directive/script.spec.js +1 -0
- package/test/directive/scrset.spec.js +2 -1
- package/test/directive/show-hide.spec.js +1 -0
- package/test/directive/src.spec.js +2 -1
- package/test/directive/style.spec.js +1 -0
- package/test/directive/switch.spec.js +2 -1
- package/test/directive/validators.spec.js +1 -1
- package/test/module-test.html +5 -5
- package/test/original-test.html +3 -3
- package/test/router/services.spec.js +1 -1
- package/test/router/state-directives.spec.js +72 -80
- package/test/router/state-filter.spec.js +6 -4
- package/test/router/state.spec.js +15 -13
- package/test/router/template-factory.spec.js +4 -4
- package/test/router/url-matcher-factory.spec.js +2 -2
- package/test/router/view-directive.spec.js +165 -163
- package/test/router/view-hook.spec.js +4 -4
- package/test/router/view-scroll.spec.js +15 -15
- package/test/router/view.spec.js +3 -3
- package/types/router/core/common/coreservices.d.ts +2 -3
- package/types/router/core/globals.d.ts +1 -4
- package/types/router/core/interface.d.ts +2 -8
- package/types/router/core/params/paramTypes.d.ts +0 -1
- package/types/router/core/router.d.ts +2 -3
- package/types/router/core/state/interface.d.ts +6 -6
- package/types/router/core/state/stateQueueManager.d.ts +1 -3
- package/types/router/core/state/stateRegistry.d.ts +1 -2
- package/types/router/core/state/stateService.d.ts +5 -6
- package/types/router/core/transition/interface.d.ts +4 -4
- package/types/router/core/transition/transitionService.d.ts +1 -2
- package/types/router/core/url/urlConfig.d.ts +1 -2
- package/types/router/core/url/urlRules.d.ts +1 -2
- package/types/router/core/url/urlService.d.ts +1 -2
- package/types/router/core/view/interface.d.ts +2 -2
- package/types/router/core/view/view.d.ts +16 -16
- package/types/router/directives/viewDirective.d.ts +3 -3
- package/types/router/interface.d.ts +4 -4
- package/types/router/locationServices.d.ts +0 -1
- package/types/router/stateProvider.d.ts +3 -3
- package/types/router/statebuilders/views.d.ts +1 -1
- package/types/router/templateFactory.d.ts +2 -2
- package/types/router/viewScroll.d.ts +1 -1
|
@@ -29,19 +29,19 @@ function parseStateRef(ref) {
|
|
|
29
29
|
}
|
|
30
30
|
/** @hidden */
|
|
31
31
|
function stateContext(el) {
|
|
32
|
-
const $
|
|
33
|
-
const path = parse("$cfg.path")($
|
|
32
|
+
const $ngView = el.parent().inheritedData("$ngView");
|
|
33
|
+
const path = parse("$cfg.path")($ngView);
|
|
34
34
|
return path ? tail(path).state.name : undefined;
|
|
35
35
|
}
|
|
36
36
|
/** @hidden */
|
|
37
37
|
function processedDef($state, $element, def) {
|
|
38
|
-
const
|
|
39
|
-
const
|
|
38
|
+
const ngState = def.ngState || $state.current.name;
|
|
39
|
+
const ngStateOpts = Object.assign(
|
|
40
40
|
defaultOpts($element, $state),
|
|
41
|
-
def.
|
|
41
|
+
def.ngStateOpts || {},
|
|
42
42
|
);
|
|
43
|
-
const href = $state.href(
|
|
44
|
-
return {
|
|
43
|
+
const href = $state.href(ngState, def.ngStateParams, ngStateOpts);
|
|
44
|
+
return { ngState, ngStateParams: def.ngStateParams, ngStateOpts, href };
|
|
45
45
|
}
|
|
46
46
|
/** @hidden */
|
|
47
47
|
function getTypeInfo(el) {
|
|
@@ -73,7 +73,7 @@ function clickHook(el, $state, $timeout, type, getDef) {
|
|
|
73
73
|
// HACK: This is to allow ng-clicks to be processed before the transition is initiated:
|
|
74
74
|
const transition = $timeout(function () {
|
|
75
75
|
if (!el.attr("disabled")) {
|
|
76
|
-
$state.go(target.
|
|
76
|
+
$state.go(target.ngState, target.ngStateParams, target.ngStateOpts);
|
|
77
77
|
}
|
|
78
78
|
});
|
|
79
79
|
e.preventDefault();
|
|
@@ -98,10 +98,10 @@ function defaultOpts(el, $state) {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
/** @hidden */
|
|
101
|
-
function bindEvents(element, scope, hookFn,
|
|
101
|
+
function bindEvents(element, scope, hookFn, ngStateOpts) {
|
|
102
102
|
let events;
|
|
103
|
-
if (
|
|
104
|
-
events =
|
|
103
|
+
if (ngStateOpts) {
|
|
104
|
+
events = ngStateOpts.events;
|
|
105
105
|
}
|
|
106
106
|
if (!Array.isArray(events)) {
|
|
107
107
|
events = ["click"];
|
|
@@ -196,7 +196,7 @@ function bindEvents(element, scope, hookFn, uiStateOpts) {
|
|
|
196
196
|
* ```
|
|
197
197
|
*
|
|
198
198
|
* ### Highlighting the active link
|
|
199
|
-
* This directive can be used in conjunction with [[
|
|
199
|
+
* This directive can be used in conjunction with [[ngSrefActive]] to highlight the active link.
|
|
200
200
|
*
|
|
201
201
|
* ### Examples
|
|
202
202
|
* If you have the following template:
|
|
@@ -248,34 +248,34 @@ function bindEvents(element, scope, hookFn, uiStateOpts) {
|
|
|
248
248
|
* - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example.
|
|
249
249
|
*
|
|
250
250
|
* - Unlike the parameter values expression, the state name is not `$watch`ed (for performance reasons).
|
|
251
|
-
* If you need to dynamically update the state being linked to, use the fully dynamic [[
|
|
251
|
+
* If you need to dynamically update the state being linked to, use the fully dynamic [[ngState]] directive.
|
|
252
252
|
*/
|
|
253
|
-
export let
|
|
253
|
+
export let ngSrefDirective = [
|
|
254
254
|
"$router",
|
|
255
255
|
"$timeout",
|
|
256
256
|
function $StateRefDirective($router, $timeout) {
|
|
257
257
|
const $state = $router.stateService;
|
|
258
258
|
return {
|
|
259
259
|
restrict: "A",
|
|
260
|
-
require: ["?^
|
|
261
|
-
link: (scope, element, attrs,
|
|
260
|
+
require: ["?^ngSrefActive", "?^ngSrefActiveEq"],
|
|
261
|
+
link: (scope, element, attrs, ngSrefActive) => {
|
|
262
262
|
const type = getTypeInfo(element);
|
|
263
|
-
const active =
|
|
263
|
+
const active = ngSrefActive[1] || ngSrefActive[0];
|
|
264
264
|
let unlinkInfoFn = null;
|
|
265
265
|
const rawDef = {};
|
|
266
266
|
const getDef = () => processedDef($state, element, rawDef);
|
|
267
|
-
const ref = parseStateRef(attrs.
|
|
268
|
-
rawDef.
|
|
269
|
-
rawDef.
|
|
270
|
-
? scope.$eval(attrs.
|
|
267
|
+
const ref = parseStateRef(attrs.ngSref);
|
|
268
|
+
rawDef.ngState = ref.state;
|
|
269
|
+
rawDef.ngStateOpts = attrs.ngSrefOpts
|
|
270
|
+
? scope.$eval(attrs.ngSrefOpts)
|
|
271
271
|
: {};
|
|
272
272
|
function update() {
|
|
273
273
|
const def = getDef();
|
|
274
274
|
if (unlinkInfoFn) unlinkInfoFn();
|
|
275
275
|
if (active)
|
|
276
276
|
unlinkInfoFn = active.$$addStateInfo(
|
|
277
|
-
def.
|
|
278
|
-
def.
|
|
277
|
+
def.ngState,
|
|
278
|
+
def.ngStateParams,
|
|
279
279
|
);
|
|
280
280
|
if (def.href != null) attrs.$set(type.attr, def.href);
|
|
281
281
|
}
|
|
@@ -283,123 +283,123 @@ export let uiSrefDirective = [
|
|
|
283
283
|
scope.$watch(
|
|
284
284
|
ref.paramExpr,
|
|
285
285
|
function (val) {
|
|
286
|
-
rawDef.
|
|
286
|
+
rawDef.ngStateParams = Object.assign({}, val);
|
|
287
287
|
update();
|
|
288
288
|
},
|
|
289
289
|
true,
|
|
290
290
|
);
|
|
291
|
-
rawDef.
|
|
291
|
+
rawDef.ngStateParams = Object.assign({}, scope.$eval(ref.paramExpr));
|
|
292
292
|
}
|
|
293
293
|
update();
|
|
294
294
|
scope.$on("$destroy", $router.stateRegistry.onStatesChanged(update));
|
|
295
295
|
scope.$on("$destroy", $router.transitionService.onSuccess({}, update));
|
|
296
296
|
if (!type.clickable) return;
|
|
297
297
|
const hookFn = clickHook(element, $state, $timeout, type, getDef);
|
|
298
|
-
bindEvents(element, scope, hookFn, rawDef.
|
|
298
|
+
bindEvents(element, scope, hookFn, rawDef.ngStateOpts);
|
|
299
299
|
},
|
|
300
300
|
};
|
|
301
301
|
},
|
|
302
302
|
];
|
|
303
303
|
/**
|
|
304
|
-
* `
|
|
304
|
+
* `ng-state`: A fully dynamic directive for linking to a state
|
|
305
305
|
*
|
|
306
306
|
* A directive which links to a state (and optionally, parameters).
|
|
307
307
|
* When clicked, this directive activates the linked state with the supplied parameter values.
|
|
308
308
|
*
|
|
309
|
-
* **This directive is very similar to [[
|
|
309
|
+
* **This directive is very similar to [[ngSref]], but it `$observe`s and `$watch`es/evaluates all its inputs.**
|
|
310
310
|
*
|
|
311
311
|
* A directive which links to a state (and optionally, parameters).
|
|
312
312
|
* When clicked, this directive activates the linked state with the supplied parameter values.
|
|
313
313
|
*
|
|
314
314
|
* ### Linked State
|
|
315
|
-
* The attribute value of `
|
|
315
|
+
* The attribute value of `ng-state` is an expression which is `$watch`ed and evaluated as the state to link to.
|
|
316
316
|
* **This is in contrast with `ui-sref`, which takes a state name as a string literal.**
|
|
317
317
|
*
|
|
318
318
|
* #### Example:
|
|
319
319
|
* Create a list of links.
|
|
320
320
|
* ```html
|
|
321
321
|
* <li ng-repeat="link in navlinks">
|
|
322
|
-
* <a
|
|
322
|
+
* <a ng-state="link.state">{{ link.displayName }}</a>
|
|
323
323
|
* </li>
|
|
324
324
|
* ```
|
|
325
325
|
*
|
|
326
326
|
* ### Relative Links
|
|
327
|
-
* If the expression evaluates to a relative path, it is processed like [[
|
|
327
|
+
* If the expression evaluates to a relative path, it is processed like [[ngSref]].
|
|
328
328
|
* You just need to be aware that the path is relative to the state that *created* the link.
|
|
329
|
-
* This allows a state to create relative `
|
|
329
|
+
* This allows a state to create relative `ng-state` which always targets the same destination.
|
|
330
330
|
*
|
|
331
331
|
* ### hrefs
|
|
332
332
|
* If the linked state has a URL, the directive will automatically generate and
|
|
333
333
|
* update the `href` attribute (using the [[StateService.href]] method).
|
|
334
334
|
*
|
|
335
335
|
* ### Parameter Values
|
|
336
|
-
* In addition to the state name expression, a `
|
|
337
|
-
* Param values should be provided using the `
|
|
338
|
-
* The `
|
|
336
|
+
* In addition to the state name expression, a `ng-state` can include parameter values which are applied when activating the state.
|
|
337
|
+
* Param values should be provided using the `ng-state-params` attribute.
|
|
338
|
+
* The `ng-state-params` attribute value is `$watch`ed and evaluated as an expression.
|
|
339
339
|
*
|
|
340
340
|
* #### Example:
|
|
341
341
|
* This example renders a list of links with param values.
|
|
342
342
|
* The state's `userId` parameter value comes from each user's `user.id` property.
|
|
343
343
|
* ```html
|
|
344
344
|
* <li ng-repeat="link in navlinks">
|
|
345
|
-
* <a
|
|
345
|
+
* <a ng-state="link.state" ng-state-params="link.params">{{ link.displayName }}</a>
|
|
346
346
|
* </li>
|
|
347
347
|
* ```
|
|
348
348
|
*
|
|
349
349
|
* ### Transition Options
|
|
350
|
-
* You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `
|
|
350
|
+
* You can specify [[TransitionOptions]] to pass to [[StateService.go]] by using the `ng-state-opts` attribute.
|
|
351
351
|
* Options are restricted to `location`, `inherit`, and `reload`.
|
|
352
|
-
* The value of the `
|
|
352
|
+
* The value of the `ng-state-opts` is `$watch`ed and evaluated as an expression.
|
|
353
353
|
*
|
|
354
354
|
* #### Example:
|
|
355
355
|
* ```html
|
|
356
|
-
* <a
|
|
356
|
+
* <a ng-state="returnto.state" ng-state-opts="{ reload: true }">Home</a>
|
|
357
357
|
* ```
|
|
358
358
|
*
|
|
359
359
|
* ### Other DOM Events
|
|
360
360
|
*
|
|
361
361
|
* You can also customize which DOM events to respond to (instead of `click`) by
|
|
362
|
-
* providing an `events` array in the `
|
|
362
|
+
* providing an `events` array in the `ng-state-opts` attribute.
|
|
363
363
|
*
|
|
364
364
|
* #### Example:
|
|
365
365
|
* ```html
|
|
366
|
-
* <input type="text"
|
|
366
|
+
* <input type="text" ng-state="contacts" ng-state-opts="{ events: ['change', 'blur'] }">
|
|
367
367
|
* ```
|
|
368
368
|
*
|
|
369
369
|
* ### Highlighting the active link
|
|
370
|
-
* This directive can be used in conjunction with [[
|
|
370
|
+
* This directive can be used in conjunction with [[ngSrefActive]] to highlight the active link.
|
|
371
371
|
*
|
|
372
372
|
* ### Notes
|
|
373
373
|
*
|
|
374
|
-
* - You can use `ui-params` to change **only the parameter values** by omitting the state name and supplying only `
|
|
375
|
-
* However, it might be simpler to use [[
|
|
374
|
+
* - You can use `ui-params` to change **only the parameter values** by omitting the state name and supplying only `ng-state-params`.
|
|
375
|
+
* However, it might be simpler to use [[ngSref]] parameter-only links.
|
|
376
376
|
*
|
|
377
377
|
* #### Example:
|
|
378
378
|
* Sets the `lang` parameter to `en` and remains on the same state.
|
|
379
379
|
*
|
|
380
380
|
* ```html
|
|
381
|
-
* <a
|
|
381
|
+
* <a ng-state="" ng-state-params="{ lang: 'en' }">English</a>
|
|
382
382
|
* ```
|
|
383
383
|
*
|
|
384
384
|
* - A middle-click, right-click, or ctrl-click is handled (natively) by the browser to open the href in a new window, for example.
|
|
385
385
|
* ```
|
|
386
386
|
*/
|
|
387
|
-
export let
|
|
387
|
+
export let ngStateDirective = [
|
|
388
388
|
"$router",
|
|
389
389
|
"$timeout",
|
|
390
390
|
function $StateRefDynamicDirective($router, $timeout) {
|
|
391
391
|
const $state = $router.stateService;
|
|
392
392
|
return {
|
|
393
393
|
restrict: "A",
|
|
394
|
-
require: ["?^
|
|
395
|
-
link: function (scope, element, attrs,
|
|
394
|
+
require: ["?^ngSrefActive", "?^ngSrefActiveEq"],
|
|
395
|
+
link: function (scope, element, attrs, ngSrefActive) {
|
|
396
396
|
const type = getTypeInfo(element);
|
|
397
|
-
const active =
|
|
397
|
+
const active = ngSrefActive[1] || ngSrefActive[0];
|
|
398
398
|
let unlinkInfoFn = null;
|
|
399
399
|
let hookFn;
|
|
400
400
|
const rawDef = {};
|
|
401
401
|
const getDef = () => processedDef($state, element, rawDef);
|
|
402
|
-
const inputAttrs = ["
|
|
402
|
+
const inputAttrs = ["ngState", "ngStateParams", "ngStateOpts"];
|
|
403
403
|
const watchDeregFns = inputAttrs.reduce(
|
|
404
404
|
(acc, attr) => ((acc[attr] = () => {}), acc),
|
|
405
405
|
{},
|
|
@@ -409,8 +409,8 @@ export let uiStateDirective = [
|
|
|
409
409
|
if (unlinkInfoFn) unlinkInfoFn();
|
|
410
410
|
if (active)
|
|
411
411
|
unlinkInfoFn = active.$$addStateInfo(
|
|
412
|
-
def.
|
|
413
|
-
def.
|
|
412
|
+
def.ngState,
|
|
413
|
+
def.ngStateParams,
|
|
414
414
|
);
|
|
415
415
|
if (def.href != null) attrs.$set(type.attr, def.href);
|
|
416
416
|
}
|
|
@@ -433,7 +433,7 @@ export let uiStateDirective = [
|
|
|
433
433
|
scope.$on("$destroy", $router.transitionService.onSuccess({}, update));
|
|
434
434
|
if (!type.clickable) return;
|
|
435
435
|
hookFn = clickHook(element, $state, $timeout, type, getDef);
|
|
436
|
-
bindEvents(element, scope, hookFn, rawDef.
|
|
436
|
+
bindEvents(element, scope, hookFn, rawDef.ngStateOpts);
|
|
437
437
|
},
|
|
438
438
|
};
|
|
439
439
|
},
|
|
@@ -441,26 +441,26 @@ export let uiStateDirective = [
|
|
|
441
441
|
/**
|
|
442
442
|
* `ui-sref-active` and `ui-sref-active-eq`: A directive that adds a CSS class when a `ui-sref` is active
|
|
443
443
|
*
|
|
444
|
-
* A directive working alongside [[
|
|
444
|
+
* A directive working alongside [[ngSref]] and [[ngState]] to add classes to an element when the
|
|
445
445
|
* related directive's state is active (and remove them when it is inactive).
|
|
446
446
|
*
|
|
447
447
|
* The primary use-case is to highlight the active link in navigation menus,
|
|
448
448
|
* distinguishing it from the inactive menu items.
|
|
449
449
|
*
|
|
450
|
-
* ### Linking to a `ui-sref` or `
|
|
451
|
-
* `ui-sref-active` can live on the same element as `ui-sref`/`
|
|
452
|
-
* If a `ui-sref-active` is a parent to more than one `ui-sref`/`
|
|
450
|
+
* ### Linking to a `ui-sref` or `ng-state`
|
|
451
|
+
* `ui-sref-active` can live on the same element as `ui-sref`/`ng-state`, or it can be on a parent element.
|
|
452
|
+
* If a `ui-sref-active` is a parent to more than one `ui-sref`/`ng-state`, it will apply the CSS class when **any of the links are active**.
|
|
453
453
|
*
|
|
454
454
|
* ### Matching
|
|
455
455
|
*
|
|
456
|
-
* The `ui-sref-active` directive applies the CSS class when the `ui-sref`/`
|
|
456
|
+
* The `ui-sref-active` directive applies the CSS class when the `ui-sref`/`ng-state`'s target state **or any child state is active**.
|
|
457
457
|
* This is a "fuzzy match" which uses [[StateService.includes]].
|
|
458
458
|
*
|
|
459
|
-
* The `ui-sref-active-eq` directive applies the CSS class when the `ui-sref`/`
|
|
459
|
+
* The `ui-sref-active-eq` directive applies the CSS class when the `ui-sref`/`ng-state`'s target state is directly active (not when child states are active).
|
|
460
460
|
* This is an "exact match" which uses [[StateService.is]].
|
|
461
461
|
*
|
|
462
462
|
* ### Parameter values
|
|
463
|
-
* If the `ui-sref`/`
|
|
463
|
+
* If the `ui-sref`/`ng-state` includes parameter values, the current parameter values must match the link's values for the link to be highlighted.
|
|
464
464
|
* This allows a list of links to the same state with different parameters to be rendered, and the correct one highlighted.
|
|
465
465
|
*
|
|
466
466
|
* #### Example:
|
|
@@ -530,7 +530,7 @@ export let uiStateDirective = [
|
|
|
530
530
|
*
|
|
531
531
|
* - Multiple classes may be specified in a space-separated format: `ui-sref-active='class1 class2 class3'`
|
|
532
532
|
*/
|
|
533
|
-
export let
|
|
533
|
+
export let ngSrefActiveDirective = [
|
|
534
534
|
"$state",
|
|
535
535
|
"$stateParams",
|
|
536
536
|
"$interpolate",
|
|
@@ -550,32 +550,32 @@ export let uiSrefActiveDirective = [
|
|
|
550
550
|
function ($scope, $element, $attrs) {
|
|
551
551
|
let states = [];
|
|
552
552
|
let activeEqClass;
|
|
553
|
-
let
|
|
553
|
+
let ngSrefActive;
|
|
554
554
|
// There probably isn't much point in $observing this
|
|
555
|
-
//
|
|
555
|
+
// ngSrefActive and ngSrefActiveEq share the same directive object with some
|
|
556
556
|
// slight difference in logic routing
|
|
557
557
|
activeEqClass = $interpolate(
|
|
558
|
-
$attrs.
|
|
558
|
+
$attrs.ngSrefActiveEq || "",
|
|
559
559
|
false,
|
|
560
560
|
)($scope);
|
|
561
561
|
try {
|
|
562
|
-
|
|
562
|
+
ngSrefActive = $scope.$eval($attrs.ngSrefActive);
|
|
563
563
|
} catch (e) {
|
|
564
|
-
// Do nothing.
|
|
564
|
+
// Do nothing. ngSrefActive is not a valid expression.
|
|
565
565
|
// Fall back to using $interpolate below
|
|
566
566
|
}
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
$interpolate($attrs.
|
|
570
|
-
setStatesFromDefinitionObject(
|
|
571
|
-
// Allow
|
|
567
|
+
ngSrefActive =
|
|
568
|
+
ngSrefActive ||
|
|
569
|
+
$interpolate($attrs.ngSrefActive || "", false)($scope);
|
|
570
|
+
setStatesFromDefinitionObject(ngSrefActive);
|
|
571
|
+
// Allow ngSref to communicate with ngSrefActive[Equals]
|
|
572
572
|
this.$$addStateInfo = function (newState, newParams) {
|
|
573
573
|
// we already got an explicit state provided by ui-sref-active, so we
|
|
574
574
|
// shadow the one that comes from ui-sref
|
|
575
|
-
if (isObject(
|
|
575
|
+
if (isObject(ngSrefActive) && states.length > 0) {
|
|
576
576
|
return;
|
|
577
577
|
}
|
|
578
|
-
const deregister = addState(newState, newParams,
|
|
578
|
+
const deregister = addState(newState, newParams, ngSrefActive);
|
|
579
579
|
update();
|
|
580
580
|
return deregister;
|
|
581
581
|
};
|
|
@@ -604,7 +604,7 @@ export let uiSrefActiveDirective = [
|
|
|
604
604
|
};
|
|
605
605
|
}
|
|
606
606
|
function handleStatesChanged() {
|
|
607
|
-
setStatesFromDefinitionObject(
|
|
607
|
+
setStatesFromDefinitionObject(ngSrefActive);
|
|
608
608
|
}
|
|
609
609
|
function setStatesFromDefinitionObject(statesDefinition) {
|
|
610
610
|
if (isObject(statesDefinition)) {
|
|
@@ -19,7 +19,7 @@ import { jqLite } from "../../jqLite";
|
|
|
19
19
|
* The ui-view can be targeted in a View using the name ([[Ng1StateDeclaration.views]]).
|
|
20
20
|
*
|
|
21
21
|
* - `autoscroll`: an expression. When it evaluates to true, the `ui-view` will be scrolled into view when it is activated.
|
|
22
|
-
* Uses [[$
|
|
22
|
+
* Uses [[$ngViewScroll]] to do the scrolling.
|
|
23
23
|
*
|
|
24
24
|
* - `onload`: Expression to evaluate whenever the view updates.
|
|
25
25
|
*
|
|
@@ -133,13 +133,13 @@ import { jqLite } from "../../jqLite";
|
|
|
133
133
|
* });
|
|
134
134
|
* ```
|
|
135
135
|
*/
|
|
136
|
-
export let
|
|
136
|
+
export let ngView = [
|
|
137
137
|
"$view",
|
|
138
138
|
"$animate",
|
|
139
|
-
"$
|
|
139
|
+
"$ngViewScroll",
|
|
140
140
|
"$interpolate",
|
|
141
141
|
"$q",
|
|
142
|
-
function $ViewDirective($view, $animate, $
|
|
142
|
+
function $ViewDirective($view, $animate, $ngViewScroll, $interpolate, $q) {
|
|
143
143
|
function getRenderer() {
|
|
144
144
|
return {
|
|
145
145
|
enter: function (element, target, cb) {
|
|
@@ -155,7 +155,7 @@ export let uiView = [
|
|
|
155
155
|
}
|
|
156
156
|
const rootData = {
|
|
157
157
|
$cfg: { viewDecl: { $context: $view._pluginapi._rootViewContext() } },
|
|
158
|
-
$
|
|
158
|
+
$ngView: {},
|
|
159
159
|
};
|
|
160
160
|
const directive = {
|
|
161
161
|
count: 0,
|
|
@@ -168,17 +168,17 @@ export let uiView = [
|
|
|
168
168
|
const onloadExp = attrs["onload"] || "",
|
|
169
169
|
autoScrollExp = attrs["autoscroll"],
|
|
170
170
|
renderer = getRenderer(),
|
|
171
|
-
inherited = $element.inheritedData("$
|
|
171
|
+
inherited = $element.inheritedData("$ngView") || rootData,
|
|
172
172
|
name =
|
|
173
|
-
$interpolate(attrs["
|
|
173
|
+
$interpolate(attrs["ngView"] || attrs["name"] || "")(scope) ||
|
|
174
174
|
"$default";
|
|
175
175
|
let previousEl, currentEl, currentScope, viewConfig;
|
|
176
176
|
const activeUIView = {
|
|
177
177
|
$type: "ng1",
|
|
178
178
|
id: directive.count++, // Global sequential ID for ui-view tags added to DOM
|
|
179
179
|
name: name, // ui-view name (<div ui-view="name"></div>
|
|
180
|
-
fqn: inherited.$
|
|
181
|
-
? inherited.$
|
|
180
|
+
fqn: inherited.$ngView.fqn
|
|
181
|
+
? inherited.$ngView.fqn + "." + name
|
|
182
182
|
: name, // fully qualified name, describes location in DOM
|
|
183
183
|
config: null, // The ViewConfig loaded (from a state.views definition)
|
|
184
184
|
configUpdated: configUpdatedCallback, // Called when the matching ViewConfig changes
|
|
@@ -189,7 +189,7 @@ export let uiView = [
|
|
|
189
189
|
);
|
|
190
190
|
// Allow <ui-view name="foo"><ui-view name="bar"></ui-view></ui-view>
|
|
191
191
|
// See https://github.com/angular-ui/ui-router/issues/3355
|
|
192
|
-
const fromParentTag = parse("$
|
|
192
|
+
const fromParentTag = parse("$ngView.creationContext")(inherited);
|
|
193
193
|
return fromParentTagConfig || fromParentTag;
|
|
194
194
|
},
|
|
195
195
|
};
|
|
@@ -204,7 +204,7 @@ export let uiView = [
|
|
|
204
204
|
viewConfig = config;
|
|
205
205
|
updateView(config);
|
|
206
206
|
}
|
|
207
|
-
$element.data("$
|
|
207
|
+
$element.data("$ngView", { $ngView: activeUIView });
|
|
208
208
|
updateView();
|
|
209
209
|
const unregister = $view.registerUIView(activeUIView);
|
|
210
210
|
scope.$on("$destroy", function () {
|
|
@@ -215,7 +215,7 @@ export let uiView = [
|
|
|
215
215
|
if (previousEl) {
|
|
216
216
|
trace.traceUIViewEvent(
|
|
217
217
|
"Removing (previous) el",
|
|
218
|
-
previousEl.data("$
|
|
218
|
+
previousEl.data("$ngView"),
|
|
219
219
|
);
|
|
220
220
|
previousEl.remove();
|
|
221
221
|
previousEl = null;
|
|
@@ -226,7 +226,7 @@ export let uiView = [
|
|
|
226
226
|
currentScope = null;
|
|
227
227
|
}
|
|
228
228
|
if (currentEl) {
|
|
229
|
-
const _viewData = currentEl.data("$
|
|
229
|
+
const _viewData = currentEl.data("$ngViewAnim");
|
|
230
230
|
trace.traceUIViewEvent("Animate out", _viewData);
|
|
231
231
|
renderer.leave(currentEl, function () {
|
|
232
232
|
_viewData.$$animLeave.resolve();
|
|
@@ -240,11 +240,11 @@ export let uiView = [
|
|
|
240
240
|
const newScope = scope.$new();
|
|
241
241
|
const animEnter = $q.defer(),
|
|
242
242
|
animLeave = $q.defer();
|
|
243
|
-
const $
|
|
243
|
+
const $ngViewData = {
|
|
244
244
|
$cfg: config,
|
|
245
|
-
$
|
|
245
|
+
$ngView: activeUIView,
|
|
246
246
|
};
|
|
247
|
-
const $
|
|
247
|
+
const $ngViewAnim = {
|
|
248
248
|
$animEnter: animEnter.promise,
|
|
249
249
|
$animLeave: animLeave.promise,
|
|
250
250
|
$$animLeave: animLeave,
|
|
@@ -263,8 +263,8 @@ export let uiView = [
|
|
|
263
263
|
*/
|
|
264
264
|
newScope.$emit("$viewContentLoading", name);
|
|
265
265
|
const cloned = $transclude(newScope, function (clone) {
|
|
266
|
-
clone.data("$
|
|
267
|
-
clone.data("$
|
|
266
|
+
clone.data("$ngViewAnim", $ngViewAnim);
|
|
267
|
+
clone.data("$ngView", $ngViewData);
|
|
268
268
|
renderer.enter(clone, $element, function () {
|
|
269
269
|
animEnter.resolve();
|
|
270
270
|
if (currentScope)
|
|
@@ -273,7 +273,7 @@ export let uiView = [
|
|
|
273
273
|
(isDefined(autoScrollExp) && !autoScrollExp) ||
|
|
274
274
|
scope.$eval(autoScrollExp)
|
|
275
275
|
) {
|
|
276
|
-
$
|
|
276
|
+
$ngViewScroll(clone);
|
|
277
277
|
}
|
|
278
278
|
});
|
|
279
279
|
cleanupLastView();
|
|
@@ -322,7 +322,7 @@ export function $ViewDirectiveFill(
|
|
|
322
322
|
const initial = tElement.html();
|
|
323
323
|
tElement.empty();
|
|
324
324
|
return function (scope, $element) {
|
|
325
|
-
const data = $element.data("$
|
|
325
|
+
const data = $element.data("$ngView");
|
|
326
326
|
if (!data) {
|
|
327
327
|
$element.html(initial);
|
|
328
328
|
$compile($element[0].contentDocument || $element[0].childNodes)(
|
|
@@ -333,7 +333,7 @@ export function $ViewDirectiveFill(
|
|
|
333
333
|
const cfg = data.$cfg || { viewDecl: {}, getTemplate: () => {} };
|
|
334
334
|
const resolveCtx = cfg.path && new ResolveContext(cfg.path);
|
|
335
335
|
$element.html(cfg.getTemplate($element, resolveCtx) || initial);
|
|
336
|
-
trace.traceUIViewFill(data.$
|
|
336
|
+
trace.traceUIViewFill(data.$ngView, $element.html());
|
|
337
337
|
const link = $compile(
|
|
338
338
|
$element[0].contentDocument || $element[0].childNodes,
|
|
339
339
|
);
|
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
import { Transition } from "../transition/transition";
|
|
2
|
-
import { UIRouter } from "../router";
|
|
3
2
|
import { Resolvable } from "../resolve/resolvable";
|
|
4
3
|
import { inArray, uniqR, unnestR } from "../../shared/common";
|
|
5
|
-
|
|
6
|
-
trans.addResolvable(Resolvable.fromData(UIRouter, trans.router), "");
|
|
7
|
-
trans.addResolvable(Resolvable.fromData(Transition, trans), "");
|
|
8
|
-
trans.addResolvable(Resolvable.fromData("$transition$", trans), "");
|
|
9
|
-
trans.addResolvable(Resolvable.fromData("$stateParams", trans.params()), "");
|
|
10
|
-
trans.entering().forEach((state) => {
|
|
11
|
-
trans.addResolvable(Resolvable.fromData("$state$", state), state);
|
|
12
|
-
});
|
|
13
|
-
}
|
|
4
|
+
|
|
14
5
|
export function registerAddCoreResolvables(transitionService) {
|
|
15
|
-
transitionService.onCreate({}, addCoreResolvables)
|
|
6
|
+
transitionService.onCreate({}, function addCoreResolvables(trans) {
|
|
7
|
+
trans.addResolvable(Resolvable.fromData(Transition, trans), "");
|
|
8
|
+
trans.addResolvable(Resolvable.fromData("$transition$", trans), "");
|
|
9
|
+
trans.addResolvable(
|
|
10
|
+
Resolvable.fromData("$stateParams", trans.params()),
|
|
11
|
+
"",
|
|
12
|
+
);
|
|
13
|
+
trans.entering().forEach((state) => {
|
|
14
|
+
trans.addResolvable(Resolvable.fromData("$state$", state), state);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const TRANSITION_TOKENS = ["$transition$", Transition];
|
|
@@ -12,7 +12,7 @@ function ignoredHook(trans) {
|
|
|
12
12
|
const ignoredReason = trans._ignoredReason();
|
|
13
13
|
if (!ignoredReason) return;
|
|
14
14
|
trace.traceTransitionIgnored(trans);
|
|
15
|
-
const pending = trans.
|
|
15
|
+
const pending = trans.globals.transition;
|
|
16
16
|
// The user clicked a link going back to the *current state* ('A')
|
|
17
17
|
// However, there is also a pending transition in flight (to 'B')
|
|
18
18
|
// Abort the transition to 'B' because the user now wants to be back at 'A'.
|
|
@@ -23,45 +23,46 @@ import { services } from "../common/coreservices";
|
|
|
23
23
|
*
|
|
24
24
|
* See [[StateDeclaration.lazyLoad]]
|
|
25
25
|
*/
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
const orig = transition.targetState();
|
|
33
|
-
return router.stateService.target(
|
|
34
|
-
orig.identifier(),
|
|
35
|
-
orig.params(),
|
|
36
|
-
orig.options(),
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
// The original transition was triggered via url sync
|
|
40
|
-
// Run the URL rules and find the best match
|
|
41
|
-
const $url = router.urlService;
|
|
42
|
-
const result = $url.match($url.parts());
|
|
43
|
-
const rule = result && result.rule;
|
|
44
|
-
// If the best match is a state, redirect the transition (instead
|
|
45
|
-
// of calling sync() which supersedes the current transition)
|
|
46
|
-
if (rule && rule.type === "STATE") {
|
|
47
|
-
const state = rule.state;
|
|
48
|
-
const params = result.match;
|
|
49
|
-
return router.stateService.target(state, params, transition.options());
|
|
50
|
-
}
|
|
51
|
-
// No matching state found, so let .sync() choose the best non-state match/otherwise
|
|
52
|
-
router.urlService.sync();
|
|
53
|
-
}
|
|
54
|
-
const promises = transition
|
|
55
|
-
.entering()
|
|
56
|
-
.filter((state) => !!state.$$state().lazyLoad)
|
|
57
|
-
.map((state) => lazyLoadState(transition, state));
|
|
58
|
-
return services.$q.all(promises).then(retryTransition);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
export function registerLazyLoadHook(transitionService) {
|
|
26
|
+
export function registerLazyLoadHook(
|
|
27
|
+
transitionService,
|
|
28
|
+
stateService,
|
|
29
|
+
urlService,
|
|
30
|
+
stateRegistry,
|
|
31
|
+
) {
|
|
62
32
|
return transitionService.onBefore(
|
|
63
33
|
{ entering: (state) => !!state.lazyLoad },
|
|
64
|
-
|
|
34
|
+
(transition) => {
|
|
35
|
+
function retryTransition() {
|
|
36
|
+
if (transition.originalTransition().options().source !== "url") {
|
|
37
|
+
// The original transition was not triggered via url sync
|
|
38
|
+
// The lazy state should be loaded now, so re-try the original transition
|
|
39
|
+
const orig = transition.targetState();
|
|
40
|
+
return stateService.target(
|
|
41
|
+
orig.identifier(),
|
|
42
|
+
orig.params(),
|
|
43
|
+
orig.options(),
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
// The original transition was triggered via url sync
|
|
47
|
+
// Run the URL rules and find the best match
|
|
48
|
+
const result = urlService.match(urlService.parts());
|
|
49
|
+
const rule = result && result.rule;
|
|
50
|
+
// If the best match is a state, redirect the transition (instead
|
|
51
|
+
// of calling sync() which supersedes the current transition)
|
|
52
|
+
if (rule && rule.type === "STATE") {
|
|
53
|
+
const state = rule.state;
|
|
54
|
+
const params = result.match;
|
|
55
|
+
return stateService.target(state, params, transition.options());
|
|
56
|
+
}
|
|
57
|
+
// No matching state found, so let .sync() choose the best non-state match/otherwise
|
|
58
|
+
urlService.sync();
|
|
59
|
+
}
|
|
60
|
+
const promises = transition
|
|
61
|
+
.entering()
|
|
62
|
+
.filter((state) => !!state.$$state().lazyLoad)
|
|
63
|
+
.map((state) => lazyLoadState(transition, state, stateRegistry));
|
|
64
|
+
return services.$q.all(promises).then(retryTransition);
|
|
65
|
+
},
|
|
65
66
|
);
|
|
66
67
|
}
|
|
67
68
|
|
|
@@ -72,7 +73,7 @@ export function registerLazyLoadHook(transitionService) {
|
|
|
72
73
|
* @param state the state to lazy load
|
|
73
74
|
* @returns A promise for the lazy load result
|
|
74
75
|
*/
|
|
75
|
-
export function lazyLoadState(transition, state) {
|
|
76
|
+
export function lazyLoadState(transition, state, stateRegistry) {
|
|
76
77
|
const lazyLoadFn = state.$$state().lazyLoad;
|
|
77
78
|
// Store/get the lazy load promise on/from the hookfn so it doesn't get re-invoked
|
|
78
79
|
let promise = lazyLoadFn["_promise"];
|
|
@@ -95,9 +96,7 @@ export function lazyLoadState(transition, state) {
|
|
|
95
96
|
/** Register any lazy loaded state definitions */
|
|
96
97
|
function updateStateRegistry(result) {
|
|
97
98
|
if (result && Array.isArray(result.states)) {
|
|
98
|
-
result.states.forEach((_state) =>
|
|
99
|
-
transition.router.stateRegistry.register(_state),
|
|
100
|
-
);
|
|
99
|
+
result.states.forEach((_state) => stateRegistry.register(_state));
|
|
101
100
|
}
|
|
102
101
|
return result;
|
|
103
102
|
}
|