@angular-wave/angular.ts 0.0.28 → 0.0.30
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/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/index.html +2 -2
- package/package.json +1 -1
- package/src/core/controller.js +3 -0
- package/src/directive/controller.js +0 -56
- package/src/directive/controller.md +46 -0
- package/src/router/common/trace.js +7 -7
- package/src/router/directives/state-directives.js +75 -75
- package/src/router/directives/view-directive.js +21 -21
- package/src/router/hooks/update-globals.js +1 -1
- package/src/router/index.js +12 -12
- package/src/router/injectables.js +11 -11
- package/src/router/resolve/resolve-context.js +1 -1
- package/src/router/router.js +8 -77
- package/src/router/services.js +5 -43
- package/src/router/state/state-builder.js +1 -0
- package/src/router/state/state-object.js +1 -1
- package/src/router/state/state-registry.js +56 -3
- package/src/router/state/state-service.js +16 -25
- package/src/router/state/target-state.js +1 -1
- package/src/router/state/views.js +5 -5
- 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/transition-service.js +2 -3
- package/src/router/url/url-config.js +0 -2
- package/src/router/url/url-matcher-factory.js +0 -1
- package/src/router/url/url-matcher.js +0 -8
- package/src/router/url/url-router.js +4 -0
- package/src/router/url/url-service.js +6 -6
- package/src/router/view/view.js +67 -65
- package/src/services/browser.js +1 -5
- package/src/shared/common.js +1 -1
- package/test/core/pubsub.spec.js +73 -0
- 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 +2 -2
- package/test/router/view-scroll.spec.js +14 -14
- package/test/router/view.spec.js +2 -2
- package/types/router/core/common/coreservices.d.ts +2 -2
- package/types/router/core/common/trace.d.ts +7 -7
- package/types/router/core/globals.d.ts +2 -1
- package/types/router/core/interface.d.ts +3 -10
- package/types/router/core/params/interface.d.ts +3 -3
- package/types/router/core/resolve/resolveContext.d.ts +4 -4
- package/types/router/core/router.d.ts +5 -51
- package/types/router/core/state/interface.d.ts +12 -12
- package/types/router/core/state/stateObject.d.ts +1 -1
- package/types/router/core/state/stateQueueManager.d.ts +2 -2
- package/types/router/core/state/stateRegistry.d.ts +5 -4
- package/types/router/core/state/stateService.d.ts +13 -13
- package/types/router/core/state/targetState.d.ts +1 -1
- package/types/router/core/transition/interface.d.ts +2 -2
- package/types/router/core/transition/transition.d.ts +12 -12
- package/types/router/core/transition/transitionService.d.ts +5 -5
- package/types/router/core/url/interface.d.ts +3 -3
- package/types/router/core/url/urlConfig.d.ts +3 -3
- package/types/router/core/url/urlMatcherFactory.d.ts +3 -3
- package/types/router/core/url/urlRouter.d.ts +2 -2
- package/types/router/core/url/urlRule.d.ts +6 -6
- package/types/router/core/url/urlRules.d.ts +6 -6
- package/types/router/core/url/urlService.d.ts +8 -8
- package/types/router/core/view/interface.d.ts +3 -3
- package/types/router/core/view/view.d.ts +26 -26
- package/types/router/directives/viewDirective.d.ts +6 -6
- package/types/router/interface.d.ts +8 -8
- package/types/router/locationServices.d.ts +3 -3
- package/types/router/services.d.ts +1 -1
- package/types/router/stateProvider.d.ts +5 -5
- package/types/router/statebuilders/views.d.ts +1 -1
- package/types/router/templateFactory.d.ts +2 -2
- package/types/router/viewScroll.d.ts +2 -2
|
@@ -3,8 +3,8 @@ import { Angular } from "../../src/loader";
|
|
|
3
3
|
import { publishExternalAPI } from "../../src/public";
|
|
4
4
|
import { browserTrigger, wait } from "../test-utils";
|
|
5
5
|
|
|
6
|
-
describe("
|
|
7
|
-
window.location.hash = "
|
|
6
|
+
describe("ngStateRef", () => {
|
|
7
|
+
window.location.hash = "";
|
|
8
8
|
let el,
|
|
9
9
|
el2,
|
|
10
10
|
template,
|
|
@@ -21,7 +21,7 @@ describe("uiStateRef", () => {
|
|
|
21
21
|
beforeEach(() => {
|
|
22
22
|
window.angular = new Angular();
|
|
23
23
|
publishExternalAPI();
|
|
24
|
-
let module = window.angular.module("defaultModule", ["
|
|
24
|
+
let module = window.angular.module("defaultModule", ["ng.router"]);
|
|
25
25
|
module.config(($stateProvider, $locationProvider) => {
|
|
26
26
|
_locationProvider = $locationProvider;
|
|
27
27
|
$locationProvider.hashPrefix("");
|
|
@@ -33,18 +33,18 @@ describe("uiStateRef", () => {
|
|
|
33
33
|
name: "contacts",
|
|
34
34
|
url: "/contacts",
|
|
35
35
|
template:
|
|
36
|
-
'<a
|
|
36
|
+
'<a ng-sref=".item({ id: 5 })" class="item">Person</a> <ng-view></ng-view>',
|
|
37
37
|
})
|
|
38
38
|
.state({
|
|
39
39
|
name: "contacts.item",
|
|
40
40
|
url: "/{id:int}",
|
|
41
41
|
template:
|
|
42
|
-
'<a
|
|
42
|
+
'<a ng-sref=".detail" class="item-detail">Detail</a> | <a ng-sref="^" class="item-parent">Parent</a> | <ng-view></ng-view>',
|
|
43
43
|
})
|
|
44
44
|
.state({
|
|
45
45
|
name: "contacts.item.detail",
|
|
46
46
|
template:
|
|
47
|
-
'<div class="title">Detail</div> | <a
|
|
47
|
+
'<div class="title">Detail</div> | <a ng-sref="^" class="item-parent2">Item</a>',
|
|
48
48
|
});
|
|
49
49
|
});
|
|
50
50
|
$injector = window.angular.bootstrap(document.getElementById("dummy"), [
|
|
@@ -58,13 +58,13 @@ describe("uiStateRef", () => {
|
|
|
58
58
|
$stateParams = $injector.get("$stateParams");
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
afterEach(() => (window.location.hash = "
|
|
61
|
+
afterEach(() => (window.location.hash = ""));
|
|
62
62
|
|
|
63
63
|
describe("links with promises", () => {
|
|
64
64
|
it("should update the href when promises on parameters change before scope is applied", async () => {
|
|
65
65
|
const defer = $q.defer();
|
|
66
66
|
el = jqLite(
|
|
67
|
-
'<a
|
|
67
|
+
'<a ng-sref="contacts.item.detail({ id: contact.id })">Details</a>',
|
|
68
68
|
);
|
|
69
69
|
defer.promise.then((val) => {
|
|
70
70
|
$rootScope.contact = val;
|
|
@@ -80,9 +80,9 @@ describe("uiStateRef", () => {
|
|
|
80
80
|
function buildDOM() {
|
|
81
81
|
window.location.hash = "#";
|
|
82
82
|
el = jqLite(
|
|
83
|
-
'<a
|
|
83
|
+
'<a ng-sref="contacts.item.detail({ id: contact.id })">Details</a>',
|
|
84
84
|
);
|
|
85
|
-
el2 = jqLite('<a
|
|
85
|
+
el2 = jqLite('<a ng-sref="top">Top</a>');
|
|
86
86
|
scope = $rootScope;
|
|
87
87
|
scope.contact = { id: 5 };
|
|
88
88
|
scope.$apply();
|
|
@@ -110,7 +110,7 @@ describe("uiStateRef", () => {
|
|
|
110
110
|
|
|
111
111
|
it("should allow multi-line attribute values", async () => {
|
|
112
112
|
el = jqLite(
|
|
113
|
-
'<a
|
|
113
|
+
'<a ng-sref="contacts.item.detail({\n\tid: $index\n})">Details</a>',
|
|
114
114
|
);
|
|
115
115
|
$rootScope.$index = 3;
|
|
116
116
|
$rootScope.$apply();
|
|
@@ -194,7 +194,7 @@ describe("uiStateRef", () => {
|
|
|
194
194
|
$rootScope.$index = "def";
|
|
195
195
|
$rootScope.$digest();
|
|
196
196
|
|
|
197
|
-
el = jqLite('<a
|
|
197
|
+
el = jqLite('<a ng-sref="{id: $index}">Details</a>');
|
|
198
198
|
$compile(el)($rootScope);
|
|
199
199
|
$rootScope.$digest();
|
|
200
200
|
|
|
@@ -226,7 +226,7 @@ describe("uiStateRef", () => {
|
|
|
226
226
|
$state.go("contacts.item.detail", { id: "123" });
|
|
227
227
|
$rootScope.$digest();
|
|
228
228
|
|
|
229
|
-
el = jqLite('<a
|
|
229
|
+
el = jqLite('<a ng-sref="{\n\tid: $index\n}">Details</a>');
|
|
230
230
|
$rootScope.$index = 3;
|
|
231
231
|
$rootScope.$apply();
|
|
232
232
|
|
|
@@ -237,7 +237,7 @@ describe("uiStateRef", () => {
|
|
|
237
237
|
|
|
238
238
|
it("should take an object as a parameter and update properly on digest churns", async () => {
|
|
239
239
|
el = jqLite(
|
|
240
|
-
'<div><a
|
|
240
|
+
'<div><a ng-sref="contacts.item.detail(urlParams)">Contacts</a></div>',
|
|
241
241
|
);
|
|
242
242
|
template = $compile(el)($rootScope);
|
|
243
243
|
|
|
@@ -293,7 +293,7 @@ describe("uiStateRef", () => {
|
|
|
293
293
|
|
|
294
294
|
beforeEach(() => {
|
|
295
295
|
el = jqLite(
|
|
296
|
-
'<a
|
|
296
|
+
'<a ng-sref-active="active" ng-sref-active-eq="activeeq" ng-state="state" ng-state-params="params">state</a>',
|
|
297
297
|
);
|
|
298
298
|
scope = $rootScope;
|
|
299
299
|
Object.assign(scope, { state: "contacts", params: {} });
|
|
@@ -318,7 +318,7 @@ describe("uiStateRef", () => {
|
|
|
318
318
|
expect(jqLite(template[0]).attr("href")).toBe("#/contacts/25");
|
|
319
319
|
});
|
|
320
320
|
|
|
321
|
-
it("updates a linked
|
|
321
|
+
it("updates a linked ng-sref-active", async () => {
|
|
322
322
|
expect(template[0].className).not.toContain("active");
|
|
323
323
|
expect(template[0].className).not.toContain("activeeq");
|
|
324
324
|
|
|
@@ -361,14 +361,13 @@ describe("uiStateRef", () => {
|
|
|
361
361
|
expect(jqLite(template[0]).attr("href")).toBe("#/other/123");
|
|
362
362
|
});
|
|
363
363
|
|
|
364
|
-
it("should allow passing params to current state using empty
|
|
365
|
-
$state.go("other", { id: "abc" });
|
|
364
|
+
it("should allow passing params to current state using empty ng-state", async () => {
|
|
365
|
+
await $state.go("other", { id: "abc" });
|
|
366
366
|
$rootScope.$index = "def";
|
|
367
367
|
$rootScope.$digest();
|
|
368
368
|
|
|
369
|
-
el = jqLite('<a
|
|
369
|
+
el = jqLite('<a ng-state="" ng-state-params="{id: $index}">Details</a>');
|
|
370
370
|
$compile(el)($rootScope);
|
|
371
|
-
$rootScope.$digest();
|
|
372
371
|
|
|
373
372
|
expect($state.current.name).toBe("other");
|
|
374
373
|
expect($state.params.id).toEqual("abc");
|
|
@@ -381,7 +380,7 @@ describe("uiStateRef", () => {
|
|
|
381
380
|
expect($state.params.id).toEqual("def");
|
|
382
381
|
|
|
383
382
|
$rootScope.$index = "ghi";
|
|
384
|
-
$state.go("other.detail");
|
|
383
|
+
await $state.go("other.detail");
|
|
385
384
|
$rootScope.$digest();
|
|
386
385
|
|
|
387
386
|
expect($state.current.name).toBe("other.detail");
|
|
@@ -423,7 +422,7 @@ describe("uiStateRef", () => {
|
|
|
423
422
|
|
|
424
423
|
it("watches attributes", () => {
|
|
425
424
|
el = jqLite(
|
|
426
|
-
'<a
|
|
425
|
+
'<a ng-state="{{exprvar}}" ng-state-params="params">state</a>',
|
|
427
426
|
);
|
|
428
427
|
template = $compile(el)(scope);
|
|
429
428
|
|
|
@@ -440,7 +439,7 @@ describe("uiStateRef", () => {
|
|
|
440
439
|
});
|
|
441
440
|
|
|
442
441
|
it("allows one-time-binding on ng1.3+", () => {
|
|
443
|
-
el = jqLite('<a
|
|
442
|
+
el = jqLite('<a ng-state="::state" ng-state-params="::params">state</a>');
|
|
444
443
|
|
|
445
444
|
scope.state = "contacts.item";
|
|
446
445
|
scope.params = { id: 10 };
|
|
@@ -458,7 +457,7 @@ describe("uiStateRef", () => {
|
|
|
458
457
|
it("accepts option overrides", async () => {
|
|
459
458
|
let transitionOptions;
|
|
460
459
|
|
|
461
|
-
el = jqLite('<a
|
|
460
|
+
el = jqLite('<a ng-state="state" ng-state-opts="opts">state</a>');
|
|
462
461
|
scope.state = "contacts";
|
|
463
462
|
scope.opts = { reload: true };
|
|
464
463
|
template = $compile(el)(scope);
|
|
@@ -480,12 +479,10 @@ describe("uiStateRef", () => {
|
|
|
480
479
|
it("should bind click event by default", async () => {
|
|
481
480
|
expect($state.current.name).toBe("top");
|
|
482
481
|
|
|
483
|
-
el = jqLite('<a
|
|
482
|
+
el = jqLite('<a ng-state="state"></a>');
|
|
484
483
|
|
|
485
484
|
scope.state = "contacts";
|
|
486
485
|
$compile(el)(scope);
|
|
487
|
-
scope.$digest();
|
|
488
|
-
|
|
489
486
|
browserTrigger(el, "click");
|
|
490
487
|
await wait(100);
|
|
491
488
|
|
|
@@ -496,7 +493,7 @@ describe("uiStateRef", () => {
|
|
|
496
493
|
expect($state.current.name).toEqual("top");
|
|
497
494
|
|
|
498
495
|
el = jqLite(
|
|
499
|
-
'<input type="text"
|
|
496
|
+
'<input type="text" ng-state="state" ng-state-opts="{ events: [\'change\'] }">',
|
|
500
497
|
);
|
|
501
498
|
|
|
502
499
|
scope.state = "contacts";
|
|
@@ -513,7 +510,7 @@ describe("uiStateRef", () => {
|
|
|
513
510
|
expect($state.current.name).toEqual("top");
|
|
514
511
|
|
|
515
512
|
el = jqLite(
|
|
516
|
-
'<input type="text"
|
|
513
|
+
'<input type="text" ng-state="state" ng-state-opts="{ events: [\'change\', \'blur\'] }">',
|
|
517
514
|
);
|
|
518
515
|
|
|
519
516
|
scope.state = "contacts";
|
|
@@ -539,7 +536,7 @@ describe("uiStateRef", () => {
|
|
|
539
536
|
expect($state.current.name).toEqual("top");
|
|
540
537
|
|
|
541
538
|
el = jqLite(
|
|
542
|
-
"<a
|
|
539
|
+
"<a ng-state=\"state\" ng-state-opts=\"{ events: ['mouseover', 'mousedown'] }\">",
|
|
543
540
|
);
|
|
544
541
|
|
|
545
542
|
scope.state = "contacts";
|
|
@@ -567,7 +564,7 @@ describe("uiStateRef", () => {
|
|
|
567
564
|
|
|
568
565
|
beforeEach(() => {
|
|
569
566
|
el = jqLite(
|
|
570
|
-
'<form
|
|
567
|
+
'<form ng-sref="contacts.item.detail({ id: contact.id })"></form>',
|
|
571
568
|
);
|
|
572
569
|
scope = $rootScope;
|
|
573
570
|
scope.contact = { id: 5 };
|
|
@@ -585,12 +582,12 @@ describe("uiStateRef", () => {
|
|
|
585
582
|
describe("relative transitions", () => {
|
|
586
583
|
beforeEach(() => {
|
|
587
584
|
$state.transitionTo("contacts.item", { id: 5 });
|
|
588
|
-
el = jqLite('<a
|
|
585
|
+
el = jqLite('<a ng-sref=".detail">Details</a>');
|
|
589
586
|
scope = $rootScope;
|
|
590
587
|
scope.$apply();
|
|
591
588
|
|
|
592
589
|
$compile(el)(scope);
|
|
593
|
-
template = $compile(jqLite("<div><
|
|
590
|
+
template = $compile(jqLite("<div><ng-view></ng-view><div>"))(scope);
|
|
594
591
|
scope.$digest();
|
|
595
592
|
});
|
|
596
593
|
|
|
@@ -602,9 +599,9 @@ describe("uiStateRef", () => {
|
|
|
602
599
|
expect($state.params.id).toEqual(5);
|
|
603
600
|
});
|
|
604
601
|
|
|
605
|
-
it("should resolve states from parent
|
|
602
|
+
it("should resolve states from parent ngView", async () => {
|
|
606
603
|
$state.transitionTo("contacts");
|
|
607
|
-
|
|
604
|
+
await wait(100);
|
|
608
605
|
const parentToChild = jqLite(template[0].querySelector("a.item"));
|
|
609
606
|
browserTrigger(parentToChild, "click");
|
|
610
607
|
await wait(100);
|
|
@@ -639,9 +636,8 @@ describe("uiStateRef", () => {
|
|
|
639
636
|
describe("option event", () => {
|
|
640
637
|
beforeEach(() => (window.location.hash = ""));
|
|
641
638
|
it("should bind click event by default", async () => {
|
|
642
|
-
el = jqLite('<a
|
|
639
|
+
el = jqLite('<a ng-sref="contacts"></a>');
|
|
643
640
|
$compile(el)($rootScope);
|
|
644
|
-
$rootScope.$digest();
|
|
645
641
|
|
|
646
642
|
expect($state.current.name).toEqual("top");
|
|
647
643
|
|
|
@@ -653,11 +649,9 @@ describe("uiStateRef", () => {
|
|
|
653
649
|
|
|
654
650
|
it("should bind single HTML events", async () => {
|
|
655
651
|
el = jqLite(
|
|
656
|
-
'<input type="text"
|
|
652
|
+
'<input type="text" ng-sref="contacts" ng-sref-opts="{ events: [\'change\'] }">',
|
|
657
653
|
);
|
|
658
654
|
$compile(el)($rootScope);
|
|
659
|
-
$rootScope.$digest();
|
|
660
|
-
|
|
661
655
|
expect($state.current.name).toEqual("top");
|
|
662
656
|
|
|
663
657
|
browserTrigger(el, "change");
|
|
@@ -668,10 +662,9 @@ describe("uiStateRef", () => {
|
|
|
668
662
|
|
|
669
663
|
it("should bind multiple HTML events", async () => {
|
|
670
664
|
el = jqLite(
|
|
671
|
-
'<input type="text"
|
|
665
|
+
'<input type="text" ng-sref="contacts" ng-sref-opts="{ events: [\'change\', \'blur\'] }">',
|
|
672
666
|
);
|
|
673
667
|
$compile(el)($rootScope);
|
|
674
|
-
$rootScope.$digest();
|
|
675
668
|
|
|
676
669
|
expect($state.current.name).toEqual("top");
|
|
677
670
|
|
|
@@ -679,7 +672,7 @@ describe("uiStateRef", () => {
|
|
|
679
672
|
await wait(100);
|
|
680
673
|
expect($state.current.name).toEqual("contacts");
|
|
681
674
|
|
|
682
|
-
$state.go("top");
|
|
675
|
+
await $state.go("top");
|
|
683
676
|
$rootScope.$digest();
|
|
684
677
|
|
|
685
678
|
expect($state.current.name).toEqual("top");
|
|
@@ -691,10 +684,9 @@ describe("uiStateRef", () => {
|
|
|
691
684
|
|
|
692
685
|
it("should bind multiple Mouse events", async () => {
|
|
693
686
|
el = jqLite(
|
|
694
|
-
"<a
|
|
687
|
+
"<a ng-sref=\"contacts\" ng-sref-opts=\"{ events: ['mouseover', 'mousedown'] }\">",
|
|
695
688
|
);
|
|
696
689
|
$compile(el)($rootScope);
|
|
697
|
-
$rootScope.$digest();
|
|
698
690
|
|
|
699
691
|
expect($state.current.name).toEqual("top");
|
|
700
692
|
|
|
@@ -702,7 +694,7 @@ describe("uiStateRef", () => {
|
|
|
702
694
|
await wait(100);
|
|
703
695
|
expect($state.current.name).toEqual("contacts");
|
|
704
696
|
|
|
705
|
-
$state.go("top");
|
|
697
|
+
await $state.go("top");
|
|
706
698
|
$rootScope.$digest();
|
|
707
699
|
|
|
708
700
|
expect($state.current.name).toEqual("top");
|
|
@@ -714,8 +706,8 @@ describe("uiStateRef", () => {
|
|
|
714
706
|
});
|
|
715
707
|
});
|
|
716
708
|
|
|
717
|
-
describe("
|
|
718
|
-
window.location.hash = "
|
|
709
|
+
describe("ngSrefActive", () => {
|
|
710
|
+
window.location.hash = "";
|
|
719
711
|
let el,
|
|
720
712
|
el2,
|
|
721
713
|
template,
|
|
@@ -731,10 +723,10 @@ describe("uiSrefActive", () => {
|
|
|
731
723
|
_stateProvider;
|
|
732
724
|
|
|
733
725
|
beforeEach(() => {
|
|
734
|
-
window.location.hash = "
|
|
726
|
+
window.location.hash = "";
|
|
735
727
|
window.angular = new Angular();
|
|
736
728
|
publishExternalAPI();
|
|
737
|
-
let module = window.angular.module("defaultModule", ["
|
|
729
|
+
let module = window.angular.module("defaultModule", ["ng.router"]);
|
|
738
730
|
module.config(function ($stateProvider) {
|
|
739
731
|
_stateProvider = $stateProvider;
|
|
740
732
|
$stateProvider
|
|
@@ -745,7 +737,7 @@ describe("uiSrefActive", () => {
|
|
|
745
737
|
views: {
|
|
746
738
|
$default: {
|
|
747
739
|
template:
|
|
748
|
-
'<a
|
|
740
|
+
'<a ng-sref=".item({ id: 6 })" ng-sref-active="active">Contacts</a>',
|
|
749
741
|
},
|
|
750
742
|
},
|
|
751
743
|
})
|
|
@@ -756,7 +748,7 @@ describe("uiSrefActive", () => {
|
|
|
756
748
|
name: "admin",
|
|
757
749
|
url: "/admin",
|
|
758
750
|
abstract: true,
|
|
759
|
-
template: "<
|
|
751
|
+
template: "<ng-view/>",
|
|
760
752
|
})
|
|
761
753
|
.state({ name: "admin.roles", url: "/roles?page" })
|
|
762
754
|
.state({
|
|
@@ -776,9 +768,9 @@ describe("uiSrefActive", () => {
|
|
|
776
768
|
$stateParams = $injector.get("$stateParams");
|
|
777
769
|
});
|
|
778
770
|
|
|
779
|
-
it("should update class for sibling
|
|
771
|
+
it("should update class for sibling ngSref", async () => {
|
|
780
772
|
el = jqLite(
|
|
781
|
-
'<div><a
|
|
773
|
+
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active">Contacts</a><a ng-sref="contacts.item({ id: 2 })" ng-sref-active="active">Contacts</a></div>',
|
|
782
774
|
);
|
|
783
775
|
template = $compile(el)($rootScope);
|
|
784
776
|
$rootScope.$digest();
|
|
@@ -795,7 +787,7 @@ describe("uiSrefActive", () => {
|
|
|
795
787
|
|
|
796
788
|
it("should match state's parameters", async () => {
|
|
797
789
|
el = jqLite(
|
|
798
|
-
'<div><a
|
|
790
|
+
'<div><a ng-sref="contacts.item.detail({ foo: \'bar\' })" ng-sref-active="active">Contacts</a></div>',
|
|
799
791
|
);
|
|
800
792
|
template = $compile(el)($rootScope);
|
|
801
793
|
$rootScope.$digest();
|
|
@@ -813,7 +805,7 @@ describe("uiSrefActive", () => {
|
|
|
813
805
|
// Test for #2696
|
|
814
806
|
it("should compare using typed parameters", async () => {
|
|
815
807
|
el = jqLite(
|
|
816
|
-
'<div><a
|
|
808
|
+
'<div><a ng-sref="arrayparam({ foo: [1,2,3] })" ng-sref-active="active">foo 123</a></div>',
|
|
817
809
|
);
|
|
818
810
|
template = $compile(el)($rootScope);
|
|
819
811
|
$rootScope.$digest();
|
|
@@ -834,9 +826,9 @@ describe("uiSrefActive", () => {
|
|
|
834
826
|
});
|
|
835
827
|
|
|
836
828
|
// Test for #3154
|
|
837
|
-
it("should compare
|
|
829
|
+
it("should compare ng-sref-active-eq using typed parameters", async () => {
|
|
838
830
|
el = jqLite(
|
|
839
|
-
'<div><a
|
|
831
|
+
'<div><a ng-sref="arrayparam({ foo: [1,2,3] })" ng-sref-active-eq="active">foo 123</a></div>',
|
|
840
832
|
);
|
|
841
833
|
template = $compile(el)($rootScope);
|
|
842
834
|
$rootScope.$digest();
|
|
@@ -856,9 +848,9 @@ describe("uiSrefActive", () => {
|
|
|
856
848
|
expect(jqLite(template[0].querySelector("a")).attr("class")).toBeFalsy();
|
|
857
849
|
});
|
|
858
850
|
|
|
859
|
-
it("should update in response to
|
|
851
|
+
it("should update in response to ng-sref param expression changes", async () => {
|
|
860
852
|
el = jqLite(
|
|
861
|
-
'<div><a
|
|
853
|
+
'<div><a ng-sref="contacts.item.detail({ foo: fooId })" ng-sref-active="active">Contacts</a></div>',
|
|
862
854
|
);
|
|
863
855
|
template = $compile(el)($rootScope);
|
|
864
856
|
$rootScope.fooId = "bar";
|
|
@@ -877,7 +869,7 @@ describe("uiSrefActive", () => {
|
|
|
877
869
|
|
|
878
870
|
it("should match on child states", async () => {
|
|
879
871
|
template = $compile(
|
|
880
|
-
'<div><a
|
|
872
|
+
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active">Contacts</a></div>',
|
|
881
873
|
)($rootScope);
|
|
882
874
|
$rootScope.$digest();
|
|
883
875
|
const a = jqLite(template[0].getElementsByTagName("a")[0]);
|
|
@@ -895,7 +887,7 @@ describe("uiSrefActive", () => {
|
|
|
895
887
|
|
|
896
888
|
it("should NOT match on child states when active-equals is used", async () => {
|
|
897
889
|
template = $compile(
|
|
898
|
-
'<div><a
|
|
890
|
+
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active-eq="active">Contacts</a></div>',
|
|
899
891
|
)($rootScope);
|
|
900
892
|
$rootScope.$digest();
|
|
901
893
|
const a = jqLite(template[0].getElementsByTagName("a")[0]);
|
|
@@ -911,7 +903,7 @@ describe("uiSrefActive", () => {
|
|
|
911
903
|
|
|
912
904
|
it("should match on child states when active-equals and active-equals-eq is used", async () => {
|
|
913
905
|
template = $compile(
|
|
914
|
-
'<div><a
|
|
906
|
+
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active" ng-sref-active-eq="active-eq">Contacts</a></div>',
|
|
915
907
|
)($rootScope);
|
|
916
908
|
$rootScope.$digest();
|
|
917
909
|
const a = jqLite(template[0].getElementsByTagName("a")[0]);
|
|
@@ -928,7 +920,7 @@ describe("uiSrefActive", () => {
|
|
|
928
920
|
});
|
|
929
921
|
|
|
930
922
|
it("should resolve relative state refs", async () => {
|
|
931
|
-
el = jqLite("<section><div
|
|
923
|
+
el = jqLite("<section><div ng-view></div></section>");
|
|
932
924
|
template = $compile(el)($rootScope);
|
|
933
925
|
$rootScope.$digest();
|
|
934
926
|
|
|
@@ -949,7 +941,7 @@ describe("uiSrefActive", () => {
|
|
|
949
941
|
|
|
950
942
|
it("should match on any child state refs", async () => {
|
|
951
943
|
el = jqLite(
|
|
952
|
-
'<div
|
|
944
|
+
'<div ng-sref-active="active"><a ng-sref="contacts.item({ id: 1 })">Contacts</a><a ng-sref="contacts.item({ id: 2 })">Contacts</a></div>',
|
|
953
945
|
);
|
|
954
946
|
template = $compile(el)($rootScope);
|
|
955
947
|
$rootScope.$digest();
|
|
@@ -967,7 +959,7 @@ describe("uiSrefActive", () => {
|
|
|
967
959
|
|
|
968
960
|
it("should match fuzzy on lazy loaded states", async () => {
|
|
969
961
|
el = jqLite(
|
|
970
|
-
'<div><a
|
|
962
|
+
'<div><a ng-sref="contacts.lazy" ng-sref-active="active">Lazy Contact</a></div>',
|
|
971
963
|
);
|
|
972
964
|
template = $compile(el)($rootScope);
|
|
973
965
|
await wait(100);
|
|
@@ -990,7 +982,7 @@ describe("uiSrefActive", () => {
|
|
|
990
982
|
|
|
991
983
|
it("should match exactly on lazy loaded states", async () => {
|
|
992
984
|
el = jqLite(
|
|
993
|
-
'<div><a
|
|
985
|
+
'<div><a ng-sref="contacts.lazy" ng-sref-active-eq="active">Lazy Contact</a></div>',
|
|
994
986
|
);
|
|
995
987
|
template = $compile(el)($rootScope);
|
|
996
988
|
await wait(100);
|
|
@@ -1013,7 +1005,7 @@ describe("uiSrefActive", () => {
|
|
|
1013
1005
|
|
|
1014
1006
|
it("should allow multiple classes to be supplied", async () => {
|
|
1015
1007
|
template = $compile(
|
|
1016
|
-
'<div><a
|
|
1008
|
+
'<div><a ng-sref="contacts.item({ id: 1 })" ng-sref-active="active also-active">Contacts</a></div>',
|
|
1017
1009
|
)($rootScope);
|
|
1018
1010
|
$rootScope.$digest();
|
|
1019
1011
|
const a = jqLite(template[0].getElementsByTagName("a")[0]);
|
|
@@ -1038,7 +1030,7 @@ describe("uiSrefActive", () => {
|
|
|
1038
1030
|
},
|
|
1039
1031
|
});
|
|
1040
1032
|
template = $compile(
|
|
1041
|
-
'<div
|
|
1033
|
+
'<div ng-sref-active="active"><a ng-sref="contacts.lazy.s1">Lazy</a></div><div ng-sref-active="active"><a ng-sref="contacts.lazy.s2"></a></div>',
|
|
1042
1034
|
)($rootScope);
|
|
1043
1035
|
$rootScope.$digest();
|
|
1044
1036
|
$state.transitionTo("contacts.lazy.s1");
|
|
@@ -1052,7 +1044,7 @@ describe("uiSrefActive", () => {
|
|
|
1052
1044
|
xdescribe("ng-{class,style} interface", () => {
|
|
1053
1045
|
it("should match on abstract states that are included by the current state", async () => {
|
|
1054
1046
|
el = $compile(
|
|
1055
|
-
'<div
|
|
1047
|
+
'<div ng-sref-active="{active: \'admin.*\'}"><a ng-sref-active="active" ng-sref="admin.roles">Roles</a></div>',
|
|
1056
1048
|
)($rootScope);
|
|
1057
1049
|
$state.transitionTo("admin.roles");
|
|
1058
1050
|
await wait(100);
|
|
@@ -1064,16 +1056,16 @@ describe("uiSrefActive", () => {
|
|
|
1064
1056
|
|
|
1065
1057
|
it("should match on state parameters", async () => {
|
|
1066
1058
|
el = $compile(
|
|
1067
|
-
"<div
|
|
1059
|
+
"<div ng-sref-active=\"{active: 'admin.roles({page: 1})'}\"></div>",
|
|
1068
1060
|
)($rootScope);
|
|
1069
1061
|
$state.transitionTo("admin.roles", { page: 1 });
|
|
1070
1062
|
await wait(100);
|
|
1071
1063
|
expect(el[0].className).toMatch(/active/);
|
|
1072
1064
|
});
|
|
1073
1065
|
|
|
1074
|
-
it("should shadow the state provided by
|
|
1066
|
+
it("should shadow the state provided by ng-sref", async () => {
|
|
1075
1067
|
el = $compile(
|
|
1076
|
-
'<div
|
|
1068
|
+
'<div ng-sref-active="{active: \'admin.roles({page: 1})\'}"><a ng-sref="admin.roles"></a></div>',
|
|
1077
1069
|
)($rootScope);
|
|
1078
1070
|
$state.transitionTo("admin.roles");
|
|
1079
1071
|
await wait(100);
|
|
@@ -1085,7 +1077,7 @@ describe("uiSrefActive", () => {
|
|
|
1085
1077
|
|
|
1086
1078
|
it("should support multiple <className, stateOrName> pairs", async () => {
|
|
1087
1079
|
el = $compile(
|
|
1088
|
-
"<div
|
|
1080
|
+
"<div ng-sref-active=\"{contacts: 'contacts.**', admin: 'admin.roles({page: 1})'}\"></div>",
|
|
1089
1081
|
)($rootScope);
|
|
1090
1082
|
$state.transitionTo("contacts");
|
|
1091
1083
|
await wait(100);
|
|
@@ -1100,7 +1092,7 @@ describe("uiSrefActive", () => {
|
|
|
1100
1092
|
it("should update the active classes when compiled", async () => {
|
|
1101
1093
|
$state.transitionTo("admin.roles");
|
|
1102
1094
|
await wait(100);
|
|
1103
|
-
el = $compile("<div
|
|
1095
|
+
el = $compile("<div ng-sref-active=\"{active: 'admin.roles'}\"/>")(
|
|
1104
1096
|
$rootScope,
|
|
1105
1097
|
);
|
|
1106
1098
|
$rootScope.$digest();
|
|
@@ -1122,7 +1114,7 @@ describe("uiSrefActive", () => {
|
|
|
1122
1114
|
},
|
|
1123
1115
|
});
|
|
1124
1116
|
template = $compile(
|
|
1125
|
-
'<div
|
|
1117
|
+
'<div ng-sref-active="{ active: \'contacts.lazy.s1\' }"><a ng-sref="contacts.lazy.s1">Lazy</a></div><div ng-sref-active="{ active: \'contacts.lazy.s2\' }"></div>',
|
|
1126
1118
|
)($rootScope);
|
|
1127
1119
|
$rootScope.$digest();
|
|
1128
1120
|
$state.transitionTo("contacts.lazy.s1");
|
|
@@ -1135,7 +1127,7 @@ describe("uiSrefActive", () => {
|
|
|
1135
1127
|
xdescribe("ng-{class,style} interface, and handle values as arrays", () => {
|
|
1136
1128
|
it("should match on abstract states that are included by the current state", async () => {
|
|
1137
1129
|
el = $compile(
|
|
1138
|
-
'<div
|
|
1130
|
+
'<div ng-sref-active="{active: [\'randomState.**\', \'admin.roles\']}"><a ng-sref-active="active" ng-sref="admin.roles">Roles</a></div>',
|
|
1139
1131
|
)($rootScope);
|
|
1140
1132
|
$state.transitionTo("admin.roles");
|
|
1141
1133
|
await wait(100);
|
|
@@ -1147,7 +1139,7 @@ describe("uiSrefActive", () => {
|
|
|
1147
1139
|
|
|
1148
1140
|
it("should match on state parameters", async () => {
|
|
1149
1141
|
el = $compile(
|
|
1150
|
-
"<div
|
|
1142
|
+
"<div ng-sref-active=\"{active: ['admin.roles({page: 1})']}\"></div>",
|
|
1151
1143
|
)($rootScope);
|
|
1152
1144
|
$state.transitionTo("admin.roles", { page: 1 });
|
|
1153
1145
|
await wait(100);
|
|
@@ -1156,7 +1148,7 @@ describe("uiSrefActive", () => {
|
|
|
1156
1148
|
|
|
1157
1149
|
it("should support multiple <className, stateOrName> pairs", async () => {
|
|
1158
1150
|
el = $compile(
|
|
1159
|
-
"<div
|
|
1151
|
+
"<div ng-sref-active=\"{contacts: ['contacts.item', 'contacts.item.detail'], admin: 'admin.roles({page: 1})'}\"></div>",
|
|
1160
1152
|
)($rootScope);
|
|
1161
1153
|
$state.transitionTo("contacts.item.detail", { id: 1, foo: "bar" });
|
|
1162
1154
|
await wait(100);
|
|
@@ -1172,7 +1164,7 @@ describe("uiSrefActive", () => {
|
|
|
1172
1164
|
$state.transitionTo("admin.roles");
|
|
1173
1165
|
await wait(100);
|
|
1174
1166
|
el = $compile(
|
|
1175
|
-
"<div
|
|
1167
|
+
"<div ng-sref-active=\"{active: ['admin.roles', 'admin.someOtherState']}\"/>",
|
|
1176
1168
|
)($rootScope);
|
|
1177
1169
|
$rootScope.$digest();
|
|
1178
1170
|
timeoutFlush();
|
|
@@ -5,15 +5,17 @@ describe("router filters", function () {
|
|
|
5
5
|
let module, $parse, $state, $q, $rootScope, $location;
|
|
6
6
|
|
|
7
7
|
beforeEach(() => {
|
|
8
|
+
window.location.hash = "";
|
|
8
9
|
window.angular = new Angular();
|
|
9
10
|
publishExternalAPI();
|
|
10
11
|
});
|
|
11
12
|
|
|
12
|
-
afterEach(() => (window.location.hash = "
|
|
13
|
+
afterEach(() => (window.location.hash = ""));
|
|
13
14
|
|
|
14
15
|
describe("isState filter", () => {
|
|
15
16
|
beforeEach(() => {
|
|
16
|
-
|
|
17
|
+
window.location.hash = "";
|
|
18
|
+
module = window.angular.module("defaultModule", ["ng.router"]);
|
|
17
19
|
module.config(function ($stateProvider) {
|
|
18
20
|
$stateProvider
|
|
19
21
|
.state({ name: "a", url: "/" })
|
|
@@ -73,7 +75,7 @@ describe("router filters", function () {
|
|
|
73
75
|
|
|
74
76
|
describe("includedByState filter", function () {
|
|
75
77
|
beforeEach(() => {
|
|
76
|
-
module = window.angular.module("defaultModule", ["
|
|
78
|
+
module = window.angular.module("defaultModule", ["ng.router"]);
|
|
77
79
|
module.config(function ($stateProvider) {
|
|
78
80
|
$stateProvider
|
|
79
81
|
.state({ name: "a", url: "/" })
|
|
@@ -107,7 +109,7 @@ describe("router filters", function () {
|
|
|
107
109
|
);
|
|
108
110
|
});
|
|
109
111
|
|
|
110
|
-
afterEach(() => (window.location.hash = "
|
|
112
|
+
afterEach(() => (window.location.hash = ""));
|
|
111
113
|
|
|
112
114
|
it("should return true if the current state exactly matches the input state", async () => {
|
|
113
115
|
await $state.go("a");
|