@angular-wave/angular.ts 0.4.4 → 0.4.6
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/Makefile +1 -0
- package/dist/angular-ts.esm.js +2 -2
- package/dist/angular-ts.umd.js +2 -12
- package/index.html +3 -74
- package/package.json +1 -1
- package/src/angular.spec.js +5 -0
- package/src/animations/animate-css.js +13 -5
- package/src/animations/animate-queue.js +21 -22
- package/src/animations/animate-runner.js +8 -4
- package/src/animations/animate.md +1 -1
- package/src/animations/animate.spec.js +21 -0
- package/src/animations/animation.js +1 -1
- package/src/binding.spec.js +1 -0
- package/src/core/compile/compile.js +25 -27
- package/src/core/compile/compile.spec.js +266 -17
- package/src/core/controller/controller.js +0 -2
- package/src/core/di/injector.md +1 -1
- package/src/core/di/injector.spec.js +2 -0
- package/src/core/di/internal-injector.js +1 -2
- package/src/core/interpolate/interpolate.js +12 -28
- package/src/core/interpolate/interpolate.spec.js +16 -70
- package/src/core/interval/interval-factory.js +50 -0
- package/src/core/interval/interval.html +18 -0
- package/src/core/interval/interval.js +77 -0
- package/src/core/interval/interval.md +123 -0
- package/src/core/interval/interval.spec.js +280 -0
- package/src/core/interval/interval.test.js +1 -1
- package/src/core/location/location.js +53 -59
- package/src/core/location/location.spec.js +27 -27
- package/src/core/on.spec.js +7 -0
- package/src/core/parse/interpreter.js +7 -10
- package/src/core/parse/parse.js +5 -26
- package/src/core/parse/parse.spec.js +91 -95
- package/src/core/prop.spec.js +60 -4
- package/src/core/q/q.html +18 -0
- package/src/core/q/q.js +472 -0
- package/src/core/q/q.md +211 -0
- package/src/core/q/q.spec.js +2748 -0
- package/src/core/q/q.test.js +12 -0
- package/src/core/sce/sce.spec.js +8 -0
- package/src/core/{model/model.html → scope/scope.html} +1 -1
- package/src/core/scope/scope.js +16 -15
- package/src/core/scope/scope.spec.js +1959 -24
- package/src/core/scope/scope.test.js +12 -0
- package/src/core/timeout/timeout.html +18 -0
- package/src/core/timeout/timeout.js +109 -0
- package/src/core/timeout/timeout.spec.js +354 -0
- package/src/core/timeout/timout.test.js +12 -0
- package/src/core/url-utils/url-utils.spec.js +1 -1
- package/src/directive/aria/aria.js +6 -3
- package/src/directive/aria/aria.spec.js +87 -0
- package/src/directive/attrs/attrs.spec.js +5 -0
- package/src/directive/attrs/boolean.spec.js +15 -0
- package/src/directive/attrs/element-style.spec.js +8 -0
- package/src/directive/attrs/src.spec.js +7 -0
- package/src/directive/bind/bind.spec.js +33 -0
- package/src/directive/bind/bing-html.spec.js +3 -0
- package/src/directive/class/class.js +3 -3
- package/src/directive/class/class.spec.js +75 -9
- package/src/directive/controller/controller.spec.js +13 -0
- package/src/directive/events/click.spec.js +3 -0
- package/src/directive/events/event.spec.js +6 -0
- package/src/directive/events/events.html +1 -0
- package/src/directive/form/form.js +3 -2
- package/src/directive/form/form.spec.js +65 -0
- package/src/directive/if/if.spec.js +4 -0
- package/src/directive/include/include.spec.js +59 -8
- package/src/directive/init/init.js +2 -6
- package/src/directive/init/init.spec.js +2 -0
- package/src/directive/input/input.spec.js +136 -0
- package/src/directive/messages/messages.spec.js +35 -4
- package/src/directive/model/model.js +25 -18
- package/src/directive/model/model.spec.js +49 -2
- package/src/directive/model-options/model-options.spec.js +6 -0
- package/src/directive/non-bindable/non-bindable.spec.js +1 -0
- package/src/directive/observe/observe.js +5 -1
- package/src/directive/observe/observe.spec.js +22 -0
- package/src/directive/observe/test.html +3 -11
- package/src/directive/options/options.spec.js +34 -0
- package/src/directive/ref/href.spec.js +15 -0
- package/src/directive/repeat/repeat.spec.js +135 -8
- package/src/directive/script/script.spec.js +2 -0
- package/src/directive/select/select.js +3 -3
- package/src/directive/select/select.spec.js +96 -0
- package/src/directive/show-hide/show-hide.js +2 -2
- package/src/directive/show-hide/show-hide.spec.js +19 -8
- package/src/directive/style/style.spec.js +7 -0
- package/src/directive/switch/switch.spec.js +5 -5
- package/src/directive/validators/validators.spec.js +1 -0
- package/src/loader.js +1 -0
- package/src/public.js +10 -2
- package/src/router/common/coreservices.js +2 -0
- package/src/router/directives/state-directives.js +14 -6
- package/src/router/directives/state-directives.spec.js +83 -0
- package/src/router/directives/view-directive.js +13 -4
- package/src/router/directives/view-directive.spec.js +71 -25
- package/src/router/hooks/lazy-load.js +2 -2
- package/src/router/hooks/views.js +5 -3
- package/src/router/resolve/resolvable.js +6 -3
- package/src/router/resolve/resolve-context.js +2 -2
- package/src/router/state/state-service.js +4 -4
- package/src/router/state/state.spec.js +5 -2
- package/src/router/state/state.test.js +1 -1
- package/src/router/state/views.js +10 -7
- package/src/router/template-factory.js +6 -3
- package/src/router/template-factory.spec.js +4 -0
- package/src/router/transition/transition-hook.js +1 -1
- package/src/router/transition/transition.js +1 -1
- package/src/router/view-hook.spec.js +2 -2
- package/src/router/view-scroll.js +6 -4
- package/src/services/browser.js +5 -8
- package/src/services/http/http.js +9 -6
- package/src/services/http/http.spec.js +31 -30
- package/src/services/http/template-request.spec.js +10 -0
- package/src/services/http-backend/http-backend.spec.js +3 -3
- package/src/services/template-request.js +4 -2
- package/src/shared/common.js +2 -1
- package/types/core/location/location.d.ts +37 -34
- package/types/core/parse/parse.d.ts +0 -26
- package/types/core/scope/scope.d.ts +11 -11
- package/src/core/model/model.js +0 -944
- package/src/core/model/model.spec.js +0 -3012
- package/types/core/model/model.d.ts +0 -204
|
@@ -137,7 +137,8 @@ export let ngView = [
|
|
|
137
137
|
"$animate",
|
|
138
138
|
"$ngViewScroll",
|
|
139
139
|
"$interpolate",
|
|
140
|
-
|
|
140
|
+
"$q",
|
|
141
|
+
function $ViewDirective($view, $animate, $ngViewScroll, $interpolate, $q) {
|
|
141
142
|
function getRenderer() {
|
|
142
143
|
return {
|
|
143
144
|
enter: function (element, target, cb) {
|
|
@@ -236,7 +237,6 @@ export let ngView = [
|
|
|
236
237
|
}
|
|
237
238
|
function updateView(config) {
|
|
238
239
|
const newScope = scope.$new();
|
|
239
|
-
|
|
240
240
|
const animEnter = $q.defer(),
|
|
241
241
|
animLeave = $q.defer();
|
|
242
242
|
const $ngViewData = {
|
|
@@ -292,8 +292,15 @@ $ViewDirectiveFill.$inject = [
|
|
|
292
292
|
"$controller",
|
|
293
293
|
"$transitions",
|
|
294
294
|
"$view",
|
|
295
|
+
"$q",
|
|
295
296
|
];
|
|
296
|
-
export function $ViewDirectiveFill(
|
|
297
|
+
export function $ViewDirectiveFill(
|
|
298
|
+
$compile,
|
|
299
|
+
$controller,
|
|
300
|
+
$transitions,
|
|
301
|
+
$view,
|
|
302
|
+
$q,
|
|
303
|
+
) {
|
|
297
304
|
const getControllerAs = parse("viewDecl.controllerAs");
|
|
298
305
|
const getResolveAs = parse("viewDecl.resolveAs");
|
|
299
306
|
return {
|
|
@@ -366,6 +373,7 @@ export function $ViewDirectiveFill($compile, $controller, $transitions, $view) {
|
|
|
366
373
|
function (ctrlInstance) {
|
|
367
374
|
if (!ctrlInstance) return;
|
|
368
375
|
registerControllerCallbacks(
|
|
376
|
+
$q,
|
|
369
377
|
$transitions,
|
|
370
378
|
ctrlInstance,
|
|
371
379
|
scope,
|
|
@@ -385,6 +393,7 @@ export function $ViewDirectiveFill($compile, $controller, $transitions, $view) {
|
|
|
385
393
|
let _uiCanExitId = 0;
|
|
386
394
|
/** @ignore TODO: move these callbacks to $view and/or `/hooks/components.ts` or something */
|
|
387
395
|
function registerControllerCallbacks(
|
|
396
|
+
$q,
|
|
388
397
|
$transitions,
|
|
389
398
|
controllerInstance,
|
|
390
399
|
$scope,
|
|
@@ -461,7 +470,7 @@ function registerControllerCallbacks(
|
|
|
461
470
|
let promise;
|
|
462
471
|
const ids = (trans[cacheProp] = trans[cacheProp] || {});
|
|
463
472
|
if (!prevTruthyAnswer(trans)) {
|
|
464
|
-
promise =
|
|
473
|
+
promise = $q.resolve(controllerInstance.uiCanExit(trans));
|
|
465
474
|
promise.then((val) => (ids[id] = val !== false));
|
|
466
475
|
}
|
|
467
476
|
return promise;
|
|
@@ -20,6 +20,8 @@ describe("ngView", () => {
|
|
|
20
20
|
app,
|
|
21
21
|
$injector,
|
|
22
22
|
$state,
|
|
23
|
+
$q,
|
|
24
|
+
$timeout,
|
|
23
25
|
$ngViewScroll;
|
|
24
26
|
|
|
25
27
|
const aState = {
|
|
@@ -165,10 +167,11 @@ describe("ngView", () => {
|
|
|
165
167
|
]);
|
|
166
168
|
|
|
167
169
|
$injector.invoke(
|
|
168
|
-
(_$state_, _$timeout_, $rootScope, _$compile_, _$ngViewScroll_) => {
|
|
170
|
+
(_$state_, _$q_, _$timeout_, $rootScope, _$compile_, _$ngViewScroll_) => {
|
|
169
171
|
scope = $rootScope.$new();
|
|
170
172
|
$compile = _$compile_;
|
|
171
173
|
$state = _$state_;
|
|
174
|
+
$q = _$q_;
|
|
172
175
|
$timeout = _$timeout_;
|
|
173
176
|
elem = JQLite("<div>");
|
|
174
177
|
$ngViewScroll = _$ngViewScroll_;
|
|
@@ -387,7 +390,7 @@ describe("ngView", () => {
|
|
|
387
390
|
name: "resolve",
|
|
388
391
|
resolve: {
|
|
389
392
|
user: function () {
|
|
390
|
-
return
|
|
393
|
+
return $timeout(() => {
|
|
391
394
|
return "joeschmoe";
|
|
392
395
|
}, 100);
|
|
393
396
|
},
|
|
@@ -525,16 +528,22 @@ describe("ngView", () => {
|
|
|
525
528
|
|
|
526
529
|
// Turn on the div that holds the ng-view
|
|
527
530
|
scope.someBoolean = true;
|
|
531
|
+
scope.$digest();
|
|
532
|
+
|
|
528
533
|
// Verify that the ng-view is there and it has the correct content
|
|
529
534
|
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
530
535
|
|
|
531
536
|
// Turn off the ng-view
|
|
532
537
|
scope.someBoolean = false;
|
|
538
|
+
scope.$digest();
|
|
539
|
+
|
|
533
540
|
// Verify there is no ng-view in the DOM
|
|
534
541
|
expect(elem.find("ng-view").length).toBe(0);
|
|
535
542
|
|
|
536
543
|
// Turn on the div that holds the ng-view once again
|
|
537
544
|
scope.someBoolean = true;
|
|
545
|
+
scope.$digest();
|
|
546
|
+
|
|
538
547
|
// Verify that the ng-view is there and it has the correct content
|
|
539
548
|
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
540
549
|
});
|
|
@@ -552,9 +561,13 @@ describe("ngView", () => {
|
|
|
552
561
|
expect(classes(elem.find("ng-view"))).not.toContain("someClass");
|
|
553
562
|
|
|
554
563
|
scope.showClass = true;
|
|
564
|
+
scope.$digest();
|
|
565
|
+
|
|
555
566
|
expect(classes(elem.find("ng-view"))).toContain("someClass");
|
|
556
567
|
|
|
557
568
|
scope.showClass = false;
|
|
569
|
+
scope.$digest();
|
|
570
|
+
|
|
558
571
|
expect(classes(elem.find("ng-view"))).not.toContain("someClass");
|
|
559
572
|
});
|
|
560
573
|
|
|
@@ -571,17 +584,23 @@ describe("ngView", () => {
|
|
|
571
584
|
|
|
572
585
|
// Lets add 3
|
|
573
586
|
scope.views = ["view1", "view2", "view3"];
|
|
587
|
+
scope.$digest();
|
|
588
|
+
|
|
574
589
|
// Should be 3 ng-views in the DOM
|
|
575
590
|
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
576
591
|
|
|
577
592
|
// Lets add one more - yay two-way binding
|
|
578
593
|
scope.views.push("view4");
|
|
594
|
+
scope.$digest();
|
|
595
|
+
|
|
579
596
|
// Should have 4 ng-views
|
|
580
597
|
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
581
598
|
|
|
582
599
|
// Lets remove 2 ng-views from the DOM
|
|
583
600
|
scope.views.pop();
|
|
584
601
|
scope.views.pop();
|
|
602
|
+
scope.$digest();
|
|
603
|
+
|
|
585
604
|
// Should have 2 ng-views
|
|
586
605
|
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
587
606
|
});
|
|
@@ -600,6 +619,8 @@ describe("ngView", () => {
|
|
|
600
619
|
|
|
601
620
|
scope.views = ["view1", "view2"];
|
|
602
621
|
|
|
622
|
+
scope.$digest();
|
|
623
|
+
|
|
603
624
|
let ngViews = elem.find("ng-view");
|
|
604
625
|
|
|
605
626
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -607,6 +628,8 @@ describe("ngView", () => {
|
|
|
607
628
|
expect(ngViews.eq(2).length).toBe(0);
|
|
608
629
|
|
|
609
630
|
scope.views.push("view3");
|
|
631
|
+
scope.$digest();
|
|
632
|
+
|
|
610
633
|
ngViews = elem.find("ng-view");
|
|
611
634
|
|
|
612
635
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -630,6 +653,8 @@ describe("ngView", () => {
|
|
|
630
653
|
|
|
631
654
|
scope.views = ["view1", "view2"];
|
|
632
655
|
|
|
656
|
+
scope.$digest();
|
|
657
|
+
|
|
633
658
|
let ngViews = elem.find("ng-view");
|
|
634
659
|
|
|
635
660
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -637,6 +662,8 @@ describe("ngView", () => {
|
|
|
637
662
|
expect(ngViews.eq(2).length).toBe(0);
|
|
638
663
|
|
|
639
664
|
scope.views.push("view3");
|
|
665
|
+
scope.$digest();
|
|
666
|
+
|
|
640
667
|
ngViews = elem.find("ng-view");
|
|
641
668
|
|
|
642
669
|
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
@@ -705,14 +732,14 @@ describe("ngView", () => {
|
|
|
705
732
|
// $animate.queue.shift();
|
|
706
733
|
|
|
707
734
|
// scope.classOn = true;
|
|
708
|
-
// ;
|
|
735
|
+
// scope.$digest();
|
|
709
736
|
|
|
710
737
|
// animation = $animate.queue.shift();
|
|
711
738
|
// expect(animation.event).toBe("addClass");
|
|
712
739
|
// expect(animation.element.text()).toBe(content);
|
|
713
740
|
|
|
714
741
|
// scope.classOn = false;
|
|
715
|
-
// ;
|
|
742
|
+
// scope.$digest();
|
|
716
743
|
|
|
717
744
|
// animation = $animate.queue.shift();
|
|
718
745
|
// expect(animation.event).toBe("removeClass");
|
|
@@ -736,7 +763,7 @@ describe("ngView", () => {
|
|
|
736
763
|
// expect($animate.queue.length).toBe(0);
|
|
737
764
|
|
|
738
765
|
// scope.shouldShow = true;
|
|
739
|
-
// ;
|
|
766
|
+
// scope.$digest();
|
|
740
767
|
|
|
741
768
|
// // $ViewDirective enter animation - Basically it's just the <!-- ngView --> comment
|
|
742
769
|
// animation = $animate.queue.shift();
|
|
@@ -749,7 +776,7 @@ describe("ngView", () => {
|
|
|
749
776
|
// expect(animation.element.text()).toBe(content);
|
|
750
777
|
|
|
751
778
|
// scope.shouldShow = false;
|
|
752
|
-
// ;
|
|
779
|
+
// scope.$digest();
|
|
753
780
|
|
|
754
781
|
// // ngView leave animation
|
|
755
782
|
// animation = $animate.queue.shift();
|
|
@@ -1021,6 +1048,8 @@ describe("ngView controllers or onEnter handlers", () => {
|
|
|
1021
1048
|
it("should not go into an infinite loop when controller uses $state.go", async () => {
|
|
1022
1049
|
el = JQLite("<div><ng-view></ng-view></div>");
|
|
1023
1050
|
template = $compile(el)($rootScope);
|
|
1051
|
+
$rootScope.$digest();
|
|
1052
|
+
|
|
1024
1053
|
await $state.transitionTo("aside");
|
|
1025
1054
|
await wait(100);
|
|
1026
1055
|
expect(template[0].querySelector(".aside")).toBeDefined();
|
|
@@ -1339,7 +1368,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1339
1368
|
});
|
|
1340
1369
|
|
|
1341
1370
|
const $state = svcs.$state,
|
|
1342
|
-
$httpBackend = svcs.$httpBackend
|
|
1371
|
+
$httpBackend = svcs.$httpBackend,
|
|
1372
|
+
$q = svcs.$q;
|
|
1343
1373
|
|
|
1344
1374
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1345
1375
|
$state.transitionTo("route2cmp");
|
|
@@ -1385,7 +1415,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1385
1415
|
});
|
|
1386
1416
|
|
|
1387
1417
|
const $state = svcs.$state,
|
|
1388
|
-
$httpBackend = svcs.$httpBackend
|
|
1418
|
+
$httpBackend = svcs.$httpBackend,
|
|
1419
|
+
$q = svcs.$q;
|
|
1389
1420
|
|
|
1390
1421
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1391
1422
|
$state.transitionTo("route2cmp");
|
|
@@ -1409,7 +1440,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1409
1440
|
});
|
|
1410
1441
|
|
|
1411
1442
|
const $state = svcs.$state,
|
|
1412
|
-
$httpBackend = svcs.$httpBackend
|
|
1443
|
+
$httpBackend = svcs.$httpBackend,
|
|
1444
|
+
$q = svcs.$q;
|
|
1413
1445
|
|
|
1414
1446
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1415
1447
|
$state.transitionTo("route2cmp");
|
|
@@ -1430,7 +1462,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1430
1462
|
});
|
|
1431
1463
|
|
|
1432
1464
|
const $state = svcs.$state,
|
|
1433
|
-
$httpBackend = svcs.$httpBackend
|
|
1465
|
+
$httpBackend = svcs.$httpBackend,
|
|
1466
|
+
$q = svcs.$q;
|
|
1434
1467
|
|
|
1435
1468
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1436
1469
|
$state.transitionTo("route2cmp");
|
|
@@ -1458,7 +1491,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1458
1491
|
});
|
|
1459
1492
|
|
|
1460
1493
|
const $state = svcs.$state,
|
|
1461
|
-
$httpBackend = svcs.$httpBackend
|
|
1494
|
+
$httpBackend = svcs.$httpBackend,
|
|
1495
|
+
$q = svcs.$q;
|
|
1462
1496
|
|
|
1463
1497
|
$state.transitionTo("bindingtypes");
|
|
1464
1498
|
await wait(100);
|
|
@@ -1513,7 +1547,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1513
1547
|
component: "dataComponent",
|
|
1514
1548
|
});
|
|
1515
1549
|
|
|
1516
|
-
const $state = svcs.$state
|
|
1550
|
+
const $state = svcs.$state,
|
|
1551
|
+
$q = svcs.$q;
|
|
1517
1552
|
$state.transitionTo("data");
|
|
1518
1553
|
await wait(100);
|
|
1519
1554
|
|
|
@@ -1528,7 +1563,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1528
1563
|
resolve: { dataUser: () => "user" },
|
|
1529
1564
|
});
|
|
1530
1565
|
|
|
1531
|
-
const $state = svcs.$state
|
|
1566
|
+
const $state = svcs.$state,
|
|
1567
|
+
$q = svcs.$q;
|
|
1532
1568
|
$state.transitionTo("data");
|
|
1533
1569
|
await wait(100);
|
|
1534
1570
|
|
|
@@ -1537,7 +1573,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1537
1573
|
|
|
1538
1574
|
// Test for #3239
|
|
1539
1575
|
it("should pass any bindings (wired from a parent component template via the ng-view) through to the child", async () => {
|
|
1540
|
-
const $state = svcs.$state
|
|
1576
|
+
const $state = svcs.$state,
|
|
1577
|
+
$q = svcs.$q;
|
|
1541
1578
|
|
|
1542
1579
|
$stateProvider.state({
|
|
1543
1580
|
name: "parent",
|
|
@@ -1561,7 +1598,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1561
1598
|
|
|
1562
1599
|
// Test for #3239
|
|
1563
1600
|
it("should prefer ng-view bindings over resolve data", async () => {
|
|
1564
|
-
const $state = svcs.$state
|
|
1601
|
+
const $state = svcs.$state,
|
|
1602
|
+
$q = svcs.$q;
|
|
1565
1603
|
|
|
1566
1604
|
$stateProvider.state({
|
|
1567
1605
|
name: "parent",
|
|
@@ -1590,7 +1628,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1590
1628
|
|
|
1591
1629
|
// Test for #3239
|
|
1592
1630
|
it("should prefer ng-view bindings over resolve data unless a bindings exists", async () => {
|
|
1593
|
-
const $state = svcs.$state
|
|
1631
|
+
const $state = svcs.$state,
|
|
1632
|
+
$q = svcs.$q;
|
|
1594
1633
|
|
|
1595
1634
|
$stateProvider.state({
|
|
1596
1635
|
name: "parent",
|
|
@@ -1620,7 +1659,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1620
1659
|
|
|
1621
1660
|
// Test for #3239
|
|
1622
1661
|
it("should pass & bindings (wired from a parent component via the ng-view) through to the child", async () => {
|
|
1623
|
-
const $state = svcs.$state
|
|
1662
|
+
const $state = svcs.$state,
|
|
1663
|
+
$q = svcs.$q;
|
|
1624
1664
|
$rootScope.log = [];
|
|
1625
1665
|
|
|
1626
1666
|
$stateProvider.state({
|
|
@@ -1653,8 +1693,9 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1653
1693
|
|
|
1654
1694
|
// Test for #3111
|
|
1655
1695
|
it("should bind & bindings to a resolve that returns a function", async () => {
|
|
1656
|
-
const $state = svcs.$state
|
|
1657
|
-
|
|
1696
|
+
const $state = svcs.$state,
|
|
1697
|
+
$q = svcs.$q,
|
|
1698
|
+
log = [];
|
|
1658
1699
|
|
|
1659
1700
|
$stateProvider.state({
|
|
1660
1701
|
name: "resolve",
|
|
@@ -1676,8 +1717,9 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1676
1717
|
|
|
1677
1718
|
// Test for #3111
|
|
1678
1719
|
it("should bind & bindings to a resolve that returns an array-style function", async () => {
|
|
1679
|
-
const $state = svcs.$state
|
|
1680
|
-
|
|
1720
|
+
const $state = svcs.$state,
|
|
1721
|
+
$q = svcs.$q,
|
|
1722
|
+
log = [];
|
|
1681
1723
|
|
|
1682
1724
|
$stateProvider.state({
|
|
1683
1725
|
name: "resolve",
|
|
@@ -1770,7 +1812,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1770
1812
|
};
|
|
1771
1813
|
$stateProvider.state(stateDef);
|
|
1772
1814
|
const $state = svcs.$state,
|
|
1773
|
-
$httpBackend = svcs.$httpBackend
|
|
1815
|
+
$httpBackend = svcs.$httpBackend,
|
|
1816
|
+
$q = svcs.$q;
|
|
1774
1817
|
|
|
1775
1818
|
$templateCache.set("/comp_tpl.html", "-{{ $ctrl.data }}-");
|
|
1776
1819
|
$state.transitionTo("route2cmp");
|
|
@@ -1841,7 +1884,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1841
1884
|
});
|
|
1842
1885
|
|
|
1843
1886
|
const $state = svcs.$state,
|
|
1844
|
-
$httpBackend = svcs.$httpBackend
|
|
1887
|
+
$httpBackend = svcs.$httpBackend,
|
|
1888
|
+
$q = svcs.$q;
|
|
1845
1889
|
|
|
1846
1890
|
$templateCache.set(
|
|
1847
1891
|
"/comp_tpl.html",
|
|
@@ -1870,7 +1914,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1870
1914
|
],
|
|
1871
1915
|
});
|
|
1872
1916
|
|
|
1873
|
-
const $state = svcs.$state
|
|
1917
|
+
const $state = svcs.$state,
|
|
1918
|
+
$q = svcs.$q;
|
|
1874
1919
|
|
|
1875
1920
|
$state.transitionTo("ng12-dynamic-directive", {
|
|
1876
1921
|
type: "ng12DynamicDirective",
|
|
@@ -1952,7 +1997,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1952
1997
|
});
|
|
1953
1998
|
|
|
1954
1999
|
it("should work with componentProvider", async () => {
|
|
1955
|
-
const $state = svcs.$state
|
|
2000
|
+
const $state = svcs.$state,
|
|
2001
|
+
$q = svcs.$q;
|
|
1956
2002
|
$state.go("dynamic2", { param: "abc" });
|
|
1957
2003
|
await wait(100);
|
|
1958
2004
|
$state.go("dynamic2", { param: "def" });
|
|
@@ -61,7 +61,7 @@ export function registerLazyLoadHook(
|
|
|
61
61
|
.entering()
|
|
62
62
|
.filter((state) => !!state.$$state().lazyLoad)
|
|
63
63
|
.map((state) => lazyLoadState(transition, state, stateRegistry));
|
|
64
|
-
return
|
|
64
|
+
return services.$q.all(promises).then(retryTransition);
|
|
65
65
|
},
|
|
66
66
|
);
|
|
67
67
|
}
|
|
@@ -86,7 +86,7 @@ export function lazyLoadState(transition, state, stateRegistry) {
|
|
|
86
86
|
};
|
|
87
87
|
const error = (err) => {
|
|
88
88
|
delete lazyLoadFn["_promise"];
|
|
89
|
-
return
|
|
89
|
+
return services.$q.reject(err);
|
|
90
90
|
};
|
|
91
91
|
promise = lazyLoadFn["_promise"] = services.$q
|
|
92
92
|
.resolve(lazyLoadFn(transition, state))
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { services } from "../common/coreservices";
|
|
1
2
|
/**
|
|
2
3
|
* A [[TransitionHookFn]] which waits for the views to load
|
|
3
4
|
*
|
|
@@ -7,11 +8,12 @@
|
|
|
7
8
|
* In angular 1, this includes loading the templates.
|
|
8
9
|
*/
|
|
9
10
|
const loadEnteringViews = (transition) => {
|
|
11
|
+
const $q = services.$q;
|
|
10
12
|
const enteringViews = transition.views("entering");
|
|
11
13
|
if (!enteringViews.length) return;
|
|
12
|
-
return
|
|
13
|
-
enteringViews.map((view) =>
|
|
14
|
-
|
|
14
|
+
return $q
|
|
15
|
+
.all(enteringViews.map((view) => $q.resolve(view.load())))
|
|
16
|
+
.then(() => {});
|
|
15
17
|
};
|
|
16
18
|
export const registerLoadEnteringViews = (transitionService) =>
|
|
17
19
|
transitionService.onFinish({}, loadEnteringViews);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { assert, isFunction, isObject } from "../../shared/utils";
|
|
2
|
+
import { services } from "../common/coreservices";
|
|
2
3
|
import { trace } from "../common/trace";
|
|
3
4
|
import { stringify } from "../../shared/strings";
|
|
4
5
|
import { isNullOrUndefined } from "../../shared/predicates";
|
|
@@ -33,7 +34,7 @@ export class Resolvable {
|
|
|
33
34
|
this.deps = deps || [];
|
|
34
35
|
this.data = data;
|
|
35
36
|
this.resolved = data !== undefined;
|
|
36
|
-
this.promise = this.resolved ?
|
|
37
|
+
this.promise = this.resolved ? services.$q.resolve(this.data) : undefined;
|
|
37
38
|
} else if (
|
|
38
39
|
isObject(arg1) &&
|
|
39
40
|
arg1.token &&
|
|
@@ -66,9 +67,10 @@ export class Resolvable {
|
|
|
66
67
|
* and update the Resolvable's state
|
|
67
68
|
*/
|
|
68
69
|
resolve(resolveContext, trans) {
|
|
70
|
+
const $q = services.$q;
|
|
69
71
|
// Gets all dependencies from ResolveContext and wait for them to be resolved
|
|
70
72
|
const getResolvableDependencies = () =>
|
|
71
|
-
|
|
73
|
+
$q.all(
|
|
72
74
|
resolveContext
|
|
73
75
|
.getDependencies(this)
|
|
74
76
|
.map((resolvable) => resolvable.get(resolveContext, trans)),
|
|
@@ -89,7 +91,8 @@ export class Resolvable {
|
|
|
89
91
|
return this.data;
|
|
90
92
|
};
|
|
91
93
|
// Sets the promise property first, then getsResolvableDependencies in the context of the promise chain. Always waits one tick.
|
|
92
|
-
return (this.promise =
|
|
94
|
+
return (this.promise = $q
|
|
95
|
+
.resolve()
|
|
93
96
|
.then(getResolvableDependencies)
|
|
94
97
|
.then(invokeResolveFn)
|
|
95
98
|
.then(customAsyncPolicy)
|
|
@@ -119,7 +119,7 @@ export class ResolveContext {
|
|
|
119
119
|
*
|
|
120
120
|
* @param {string} when
|
|
121
121
|
* @param trans
|
|
122
|
-
* @returns {
|
|
122
|
+
* @returns {import("../../core/q/q").QPromise<any>|any}
|
|
123
123
|
*/
|
|
124
124
|
resolvePath(when = "LAZY", trans) {
|
|
125
125
|
// This option determines which 'when' policy Resolvables we are about to fetch.
|
|
@@ -153,7 +153,7 @@ export class ResolveContext {
|
|
|
153
153
|
return acc.concat(wait.map(getResult));
|
|
154
154
|
}, []);
|
|
155
155
|
// Wait for all the "WAIT" resolvables
|
|
156
|
-
return
|
|
156
|
+
return services.$q.all(promises);
|
|
157
157
|
}
|
|
158
158
|
|
|
159
159
|
injector() {
|
|
@@ -244,7 +244,7 @@ export class StateProvider {
|
|
|
244
244
|
const nextCallback = callbackQueue.dequeue();
|
|
245
245
|
if (nextCallback === undefined)
|
|
246
246
|
return Rejection.invalid(toState.error()).toPromise();
|
|
247
|
-
const callbackResult =
|
|
247
|
+
const callbackResult = services.$q.resolve(
|
|
248
248
|
nextCallback(toState, fromState, injector),
|
|
249
249
|
);
|
|
250
250
|
return callbackResult
|
|
@@ -459,7 +459,7 @@ export class StateProvider {
|
|
|
459
459
|
if (error.type === RejectType.IGNORED) {
|
|
460
460
|
isLatest && this.urlService.update();
|
|
461
461
|
// Consider ignored `Transition.run()` as a successful `transitionTo`
|
|
462
|
-
return
|
|
462
|
+
return services.$q.resolve(this.globals.current);
|
|
463
463
|
}
|
|
464
464
|
const detail = error.detail;
|
|
465
465
|
if (
|
|
@@ -474,12 +474,12 @@ export class StateProvider {
|
|
|
474
474
|
}
|
|
475
475
|
if (error.type === RejectType.ABORTED) {
|
|
476
476
|
isLatest && this.urlService.update();
|
|
477
|
-
return
|
|
477
|
+
return services.$q.reject(error);
|
|
478
478
|
}
|
|
479
479
|
}
|
|
480
480
|
const errorHandler = this.defaultErrorHandler();
|
|
481
481
|
errorHandler(error);
|
|
482
|
-
return
|
|
482
|
+
return services.$q.reject(error);
|
|
483
483
|
};
|
|
484
484
|
const transition = this.transitionService.create(currentPath, ref);
|
|
485
485
|
const transitionToPromise = transition
|
|
@@ -12,7 +12,8 @@ describe("$state", () => {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
async function initStateTo(state, params) {
|
|
15
|
-
const $state = $get("$state")
|
|
15
|
+
const $state = $get("$state"),
|
|
16
|
+
$q = $get("$q");
|
|
16
17
|
return $state.transitionTo(state, params || {});
|
|
17
18
|
}
|
|
18
19
|
|
|
@@ -240,7 +241,7 @@ describe("$state", () => {
|
|
|
240
241
|
url: "/resolve-timeout/:foo",
|
|
241
242
|
resolve: {
|
|
242
243
|
value: function ($timeout) {
|
|
243
|
-
return
|
|
244
|
+
return $timeout(function () {
|
|
244
245
|
log += "Success!";
|
|
245
246
|
}, 1);
|
|
246
247
|
},
|
|
@@ -310,6 +311,7 @@ describe("$state", () => {
|
|
|
310
311
|
_$state_,
|
|
311
312
|
_$stateParams_,
|
|
312
313
|
_$transitions_,
|
|
314
|
+
_$q_,
|
|
313
315
|
_$location_,
|
|
314
316
|
_$compile_,
|
|
315
317
|
_$stateRegistry_,
|
|
@@ -318,6 +320,7 @@ describe("$state", () => {
|
|
|
318
320
|
$state = _$state_;
|
|
319
321
|
$stateParams = _$stateParams_;
|
|
320
322
|
$transitions = _$transitions_;
|
|
323
|
+
$q = _$q_;
|
|
321
324
|
$location = _$location_;
|
|
322
325
|
$compile = _$compile_;
|
|
323
326
|
$stateRegistry = _$stateRegistry_;
|
|
@@ -115,19 +115,22 @@ export class Ng1ViewConfig {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
load() {
|
|
118
|
+
const $q = services.$q;
|
|
118
119
|
const context = new ResolveContext(this.path);
|
|
119
120
|
const params = this.path.reduce(
|
|
120
121
|
(acc, node) => Object.assign(acc, node.paramValues),
|
|
121
122
|
{},
|
|
122
123
|
);
|
|
123
|
-
const promises =
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
124
|
+
const promises = {
|
|
125
|
+
template: $q.resolve(
|
|
126
|
+
this.factory.fromConfig(this.viewDecl, params, context),
|
|
127
|
+
),
|
|
128
|
+
controller: $q.resolve(this.getController(context)),
|
|
129
|
+
};
|
|
130
|
+
return $q.all(promises).then((results) => {
|
|
128
131
|
trace.traceViewServiceEvent("Loaded", this);
|
|
129
|
-
this.controller = results
|
|
130
|
-
Object.assign(this, results
|
|
132
|
+
this.controller = results.controller;
|
|
133
|
+
Object.assign(this, results.template); // Either { template: "tpl" } or { component: "cmpName" }
|
|
131
134
|
return this;
|
|
132
135
|
});
|
|
133
136
|
}
|
|
@@ -24,18 +24,21 @@ export class TemplateFactoryProvider {
|
|
|
24
24
|
"$http",
|
|
25
25
|
"$templateCache",
|
|
26
26
|
"$templateRequest",
|
|
27
|
+
"$q",
|
|
27
28
|
"$injector",
|
|
28
29
|
/**
|
|
29
30
|
* @param {any} $http
|
|
30
31
|
* @param {import("../core/cache/cache-factory").TemplateCache} $templateCache
|
|
31
32
|
* @param {any} $templateRequest
|
|
33
|
+
* @param {any} $q
|
|
32
34
|
* @param {import("../core/di/internal-injector").InjectorService} $injector
|
|
33
35
|
* @returns
|
|
34
36
|
*/
|
|
35
|
-
($http, $templateCache, $templateRequest, $injector) => {
|
|
37
|
+
($http, $templateCache, $templateRequest, $q, $injector) => {
|
|
36
38
|
this.$templateRequest = $templateRequest;
|
|
37
39
|
this.$http = $http;
|
|
38
40
|
this.$templateCache = $templateCache;
|
|
41
|
+
this.$q = $q;
|
|
39
42
|
this.$injector = $injector;
|
|
40
43
|
return this;
|
|
41
44
|
},
|
|
@@ -66,9 +69,9 @@ export class TemplateFactoryProvider {
|
|
|
66
69
|
fromConfig(config, params, context) {
|
|
67
70
|
const defaultTemplate = "<ui-view></ui-view>";
|
|
68
71
|
const asTemplate = (result) =>
|
|
69
|
-
|
|
72
|
+
this.$q.resolve(result).then((str) => ({ template: str }));
|
|
70
73
|
const asComponent = (result) =>
|
|
71
|
-
|
|
74
|
+
this.$q.resolve(result).then((str) => ({ component: str }));
|
|
72
75
|
|
|
73
76
|
const getConfigType = (config) => {
|
|
74
77
|
if (isDefined(config.template)) return "template";
|
|
@@ -36,6 +36,7 @@ describe("templateFactory", () => {
|
|
|
36
36
|
describe("should follow $sce policy and", () => {
|
|
37
37
|
it("accepts relative URLs", async () => {
|
|
38
38
|
let res = $templateFactory.fromUrl("mock/hello");
|
|
39
|
+
$scope.$digest();
|
|
39
40
|
await wait(100);
|
|
40
41
|
expect(res.$$state.status).toBe(1);
|
|
41
42
|
});
|
|
@@ -127,6 +128,7 @@ describe("templateFactory", () => {
|
|
|
127
128
|
it("should not prefix the components dom element with anything", async () => {
|
|
128
129
|
$stateRegistry.register({ name: "cmp", component: "myComponent" });
|
|
129
130
|
$stateService.go("cmp");
|
|
131
|
+
$scope.$digest();
|
|
130
132
|
await wait(100);
|
|
131
133
|
expect(el.html()).toMatch(/\<my-component/);
|
|
132
134
|
});
|
|
@@ -137,12 +139,14 @@ describe("templateFactory", () => {
|
|
|
137
139
|
component: "dataComponent",
|
|
138
140
|
});
|
|
139
141
|
$stateService.go("cmp");
|
|
142
|
+
$scope.$digest();
|
|
140
143
|
expect(el.html()).toMatch(/\<x-data-component/);
|
|
141
144
|
});
|
|
142
145
|
|
|
143
146
|
it("should prefix the components dom element with x- for components named xFoo", () => {
|
|
144
147
|
$stateRegistry.register({ name: "cmp", component: "xComponent" });
|
|
145
148
|
$stateService.go("cmp");
|
|
149
|
+
$scope.$digest();
|
|
146
150
|
expect(el.html()).toMatch(/\<x-x-component/);
|
|
147
151
|
});
|
|
148
152
|
});
|
|
@@ -37,7 +37,7 @@ export class TransitionHook {
|
|
|
37
37
|
// Chain the next hook off the previous
|
|
38
38
|
const createHookChainR = (prev, nextHook) =>
|
|
39
39
|
prev.then(() => nextHook.invokeHook());
|
|
40
|
-
return hooks.reduce(createHookChainR, waitFor ||
|
|
40
|
+
return hooks.reduce(createHookChainR, waitFor || services.$q.resolve());
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
43
|
* Invokes all the provided TransitionHooks, in order.
|