@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
|
@@ -11,7 +11,7 @@ import { Angular } from "../../src/loader";
|
|
|
11
11
|
import { publishExternalAPI } from "../../src/public";
|
|
12
12
|
import { wait } from "../test-utils";
|
|
13
13
|
|
|
14
|
-
describe("
|
|
14
|
+
describe("ngView", () => {
|
|
15
15
|
let $stateProvider,
|
|
16
16
|
scope,
|
|
17
17
|
$compile,
|
|
@@ -22,7 +22,7 @@ describe("uiView", () => {
|
|
|
22
22
|
$state,
|
|
23
23
|
$q,
|
|
24
24
|
$timeout,
|
|
25
|
-
$
|
|
25
|
+
$ngViewScroll;
|
|
26
26
|
|
|
27
27
|
const aState = {
|
|
28
28
|
name: "a",
|
|
@@ -53,7 +53,7 @@ describe("uiView", () => {
|
|
|
53
53
|
},
|
|
54
54
|
eState = {
|
|
55
55
|
name: "e",
|
|
56
|
-
template: '<div
|
|
56
|
+
template: '<div ng-view="eview" class="eview"></div>',
|
|
57
57
|
},
|
|
58
58
|
fState = {
|
|
59
59
|
name: "e.f",
|
|
@@ -65,7 +65,7 @@ describe("uiView", () => {
|
|
|
65
65
|
},
|
|
66
66
|
gState = {
|
|
67
67
|
name: "g",
|
|
68
|
-
template: '<div
|
|
68
|
+
template: '<div ng-view="inner"><span>{{content}}</span></div>',
|
|
69
69
|
},
|
|
70
70
|
hState = {
|
|
71
71
|
name: "g.h",
|
|
@@ -78,7 +78,7 @@ describe("uiView", () => {
|
|
|
78
78
|
iState = {
|
|
79
79
|
name: "i",
|
|
80
80
|
template:
|
|
81
|
-
"<div
|
|
81
|
+
"<div ng-view>" +
|
|
82
82
|
'<ul><li ng-repeat="item in items">{{item}}</li></ul>' +
|
|
83
83
|
"</div>",
|
|
84
84
|
},
|
|
@@ -119,7 +119,7 @@ describe("uiView", () => {
|
|
|
119
119
|
name: "n",
|
|
120
120
|
template: "nState",
|
|
121
121
|
controller: function ($scope, $element) {
|
|
122
|
-
const data = $element.data("$
|
|
122
|
+
const data = $element.data("$ngViewAnim");
|
|
123
123
|
$scope.$on("$destroy", () => {
|
|
124
124
|
log += "destroy;";
|
|
125
125
|
});
|
|
@@ -138,10 +138,10 @@ describe("uiView", () => {
|
|
|
138
138
|
publishExternalAPI();
|
|
139
139
|
log = "";
|
|
140
140
|
app = window.angular
|
|
141
|
-
.module("defaultModule", ["
|
|
141
|
+
.module("defaultModule", ["ng.router"])
|
|
142
142
|
.config(($provide, _$stateProvider_) => {
|
|
143
|
-
$provide.decorator("$
|
|
144
|
-
return jasmine.createSpy("$
|
|
143
|
+
$provide.decorator("$ngViewScroll", () => {
|
|
144
|
+
return jasmine.createSpy("$ngViewScroll");
|
|
145
145
|
});
|
|
146
146
|
|
|
147
147
|
_$stateProvider_
|
|
@@ -168,84 +168,84 @@ describe("uiView", () => {
|
|
|
168
168
|
]);
|
|
169
169
|
|
|
170
170
|
$injector.invoke(
|
|
171
|
-
(_$state_, _$q_, _$timeout_, $rootScope, _$compile_, _$
|
|
171
|
+
(_$state_, _$q_, _$timeout_, $rootScope, _$compile_, _$ngViewScroll_) => {
|
|
172
172
|
scope = $rootScope.$new();
|
|
173
173
|
$compile = _$compile_;
|
|
174
174
|
$state = _$state_;
|
|
175
175
|
$q = _$q_;
|
|
176
176
|
$timeout = _$timeout_;
|
|
177
177
|
elem = jqLite("<div>");
|
|
178
|
-
$
|
|
178
|
+
$ngViewScroll = _$ngViewScroll_;
|
|
179
179
|
},
|
|
180
180
|
);
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
describe("linking ui-directive", () => {
|
|
184
|
-
it("anonymous
|
|
185
|
-
elem.append($compile("<div><
|
|
184
|
+
it("anonymous ng-view should be replaced with the template of the current $state", async () => {
|
|
185
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
186
186
|
|
|
187
|
-
expect(elem.find("
|
|
187
|
+
expect(elem.find("ng-view").text()).toBe("");
|
|
188
188
|
|
|
189
189
|
$state.transitionTo(aState);
|
|
190
190
|
await wait(100);
|
|
191
191
|
|
|
192
|
-
expect(elem.find("
|
|
192
|
+
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
193
193
|
});
|
|
194
194
|
|
|
195
|
-
it("named
|
|
195
|
+
it("named ng-view should be replaced with the template of the current $state", async () => {
|
|
196
196
|
elem.append(
|
|
197
|
-
$compile('<div><
|
|
197
|
+
$compile('<div><ng-view name="cview"></ng-view></div>')(scope),
|
|
198
198
|
);
|
|
199
199
|
|
|
200
200
|
$state.transitionTo(cState);
|
|
201
201
|
await wait(100);
|
|
202
202
|
|
|
203
|
-
expect(elem.find("
|
|
203
|
+
expect(elem.find("ng-view").text()).toBe(cState.views.cview.template);
|
|
204
204
|
});
|
|
205
205
|
|
|
206
|
-
it("
|
|
207
|
-
elem.append($compile("<div><
|
|
208
|
-
expect(elem.find("
|
|
206
|
+
it("ng-view should be updated after transition to another state", async () => {
|
|
207
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
208
|
+
expect(elem.find("ng-view").text()).toBe("");
|
|
209
209
|
|
|
210
210
|
$state.transitionTo(aState);
|
|
211
211
|
await wait(100);
|
|
212
212
|
|
|
213
|
-
expect(elem.find("
|
|
213
|
+
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
214
214
|
|
|
215
215
|
$state.transitionTo(bState);
|
|
216
216
|
await wait(100);
|
|
217
217
|
|
|
218
|
-
expect(elem.find("
|
|
218
|
+
expect(elem.find("ng-view").text()).toBe(bState.template);
|
|
219
219
|
});
|
|
220
220
|
|
|
221
221
|
it("should handle NOT nested ui-views", async () => {
|
|
222
222
|
elem.append(
|
|
223
223
|
$compile(
|
|
224
|
-
'<div><
|
|
224
|
+
'<div><ng-view name="dview1" class="dview1"></ng-view><ng-view name="dview2" class="dview2"></ng-view></div>',
|
|
225
225
|
)(scope),
|
|
226
226
|
);
|
|
227
|
-
expect(elem.find("
|
|
228
|
-
expect(elem.find("
|
|
227
|
+
expect(elem.find("ng-view").eq(0).text()).toBe("");
|
|
228
|
+
expect(elem.find("ng-view").eq(1).text()).toBe("");
|
|
229
229
|
|
|
230
230
|
$state.transitionTo(dState);
|
|
231
231
|
await wait(100);
|
|
232
232
|
|
|
233
|
-
expect(elem.find("
|
|
233
|
+
expect(elem.find("ng-view").eq(0).text()).toBe(
|
|
234
234
|
dState.views.dview1.template,
|
|
235
235
|
);
|
|
236
|
-
expect(elem.find("
|
|
236
|
+
expect(elem.find("ng-view").eq(1).text()).toBe(
|
|
237
237
|
dState.views.dview2.template,
|
|
238
238
|
);
|
|
239
239
|
});
|
|
240
240
|
|
|
241
241
|
it("should handle nested ui-views (testing two levels deep)", async () => {
|
|
242
|
-
$compile(elem.append("<div><
|
|
243
|
-
expect(elem.find("
|
|
242
|
+
$compile(elem.append("<div><ng-view></ng-view></div>"))(scope);
|
|
243
|
+
expect(elem.find("ng-view").text()).toBe("");
|
|
244
244
|
|
|
245
245
|
$state.transitionTo(fState);
|
|
246
246
|
await wait(100);
|
|
247
247
|
|
|
248
|
-
expect(elem.find("
|
|
248
|
+
expect(elem.find("ng-view").text()).toBe(fState.views.eview.template);
|
|
249
249
|
});
|
|
250
250
|
});
|
|
251
251
|
|
|
@@ -253,36 +253,36 @@ describe("uiView", () => {
|
|
|
253
253
|
it("initial view should be compiled if the view is empty", async () => {
|
|
254
254
|
const content = "inner content";
|
|
255
255
|
scope.content = content;
|
|
256
|
-
elem.append($compile("<div><
|
|
256
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
257
257
|
|
|
258
258
|
$state.transitionTo(gState);
|
|
259
259
|
await wait(100);
|
|
260
260
|
|
|
261
|
-
expect(elem.find("
|
|
261
|
+
expect(elem.find("ng-view").text()).toBe(content);
|
|
262
262
|
});
|
|
263
263
|
|
|
264
264
|
it("initial view should be put back after removal of the view", async () => {
|
|
265
265
|
const content = "inner content";
|
|
266
266
|
scope.content = content;
|
|
267
|
-
elem.append($compile("<div><
|
|
267
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
268
268
|
|
|
269
269
|
$state.go(hState);
|
|
270
270
|
await wait(100);
|
|
271
271
|
|
|
272
|
-
expect(elem.find("
|
|
272
|
+
expect(elem.find("ng-view").text()).toBe(hState.views.inner.template);
|
|
273
273
|
|
|
274
274
|
// going to the parent state which makes the inner view empty
|
|
275
275
|
$state.go(gState);
|
|
276
276
|
await wait(100);
|
|
277
277
|
|
|
278
|
-
expect(elem.find("
|
|
278
|
+
expect(elem.find("ng-view").text()).toBe(content);
|
|
279
279
|
});
|
|
280
280
|
|
|
281
281
|
// related to issue #435
|
|
282
282
|
it("initial view should be transcluded once to prevent breaking other directives", async () => {
|
|
283
283
|
scope.items = ["I", "am", "a", "list", "of", "items"];
|
|
284
284
|
|
|
285
|
-
elem.append($compile("<div><
|
|
285
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
286
286
|
|
|
287
287
|
// transition to state that has an initial view
|
|
288
288
|
$state.transitionTo(iState);
|
|
@@ -295,7 +295,7 @@ describe("uiView", () => {
|
|
|
295
295
|
$state.transitionTo(jState);
|
|
296
296
|
await wait(100);
|
|
297
297
|
|
|
298
|
-
expect(elem.find("
|
|
298
|
+
expect(elem.find("ng-view").text()).toBe(jState.template);
|
|
299
299
|
|
|
300
300
|
// transition back to the state with empty subview and the initial view
|
|
301
301
|
$state.transitionTo(iState);
|
|
@@ -316,34 +316,34 @@ describe("uiView", () => {
|
|
|
316
316
|
|
|
317
317
|
describe("autoscroll attribute", () => {
|
|
318
318
|
it("should NOT autoscroll when unspecified", async () => {
|
|
319
|
-
elem.append($compile("<div><
|
|
319
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
320
320
|
|
|
321
321
|
$state.transitionTo(aState);
|
|
322
322
|
await wait(100);
|
|
323
|
-
expect($
|
|
323
|
+
expect($ngViewScroll).not.toHaveBeenCalled();
|
|
324
324
|
});
|
|
325
325
|
|
|
326
326
|
it("should autoscroll when expression is missing", async () => {
|
|
327
|
-
elem.append($compile("<div><
|
|
327
|
+
elem.append($compile("<div><ng-view autoscroll></ng-view></div>")(scope));
|
|
328
328
|
await $state.transitionTo(aState);
|
|
329
329
|
await wait(20);
|
|
330
330
|
|
|
331
331
|
// animateFlush($animate);
|
|
332
332
|
|
|
333
|
-
expect($
|
|
333
|
+
expect($ngViewScroll).toHaveBeenCalledWith(elem.find("ng-view"));
|
|
334
334
|
});
|
|
335
335
|
|
|
336
336
|
it("should autoscroll based on expression", async () => {
|
|
337
337
|
scope.doScroll = false;
|
|
338
338
|
|
|
339
339
|
elem.append(
|
|
340
|
-
$compile('<div><
|
|
340
|
+
$compile('<div><ng-view autoscroll="doScroll"></ng-view></div>')(scope),
|
|
341
341
|
);
|
|
342
342
|
|
|
343
343
|
$state.transitionTo(aState);
|
|
344
344
|
await wait(100);
|
|
345
345
|
|
|
346
|
-
expect($
|
|
346
|
+
expect($ngViewScroll).not.toHaveBeenCalled();
|
|
347
347
|
|
|
348
348
|
scope.doScroll = true;
|
|
349
349
|
$state.transitionTo(bState);
|
|
@@ -351,26 +351,26 @@ describe("uiView", () => {
|
|
|
351
351
|
|
|
352
352
|
let target,
|
|
353
353
|
index = -1,
|
|
354
|
-
|
|
354
|
+
ngViews = elem.find("ng-view");
|
|
355
355
|
|
|
356
|
-
while (index++ <
|
|
357
|
-
const
|
|
358
|
-
if (
|
|
356
|
+
while (index++ < ngViews.length) {
|
|
357
|
+
const ngView = jqLite(ngViews[index]);
|
|
358
|
+
if (ngView.text() === bState.template) target = ngView;
|
|
359
359
|
}
|
|
360
360
|
|
|
361
|
-
expect($
|
|
361
|
+
expect($ngViewScroll).toHaveBeenCalledWith(target);
|
|
362
362
|
});
|
|
363
363
|
});
|
|
364
364
|
|
|
365
365
|
it("should instantiate a controller with controllerAs", async () => {
|
|
366
|
-
elem.append($compile("<div><
|
|
366
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
367
367
|
await $state.transitionTo(kState);
|
|
368
368
|
expect(elem.text()).toBe("value");
|
|
369
369
|
});
|
|
370
370
|
|
|
371
371
|
it("should instantiate a controller with both $scope and $element injections", async () => {
|
|
372
372
|
elem.append(
|
|
373
|
-
$compile('<div><
|
|
373
|
+
$compile('<div><ng-view id="mState">{{elementId}}</ng-view></div>')(
|
|
374
374
|
scope,
|
|
375
375
|
),
|
|
376
376
|
);
|
|
@@ -385,17 +385,19 @@ describe("uiView", () => {
|
|
|
385
385
|
function controller($scope) {
|
|
386
386
|
_scope = $scope;
|
|
387
387
|
}
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
return
|
|
395
|
-
|
|
388
|
+
let _state;
|
|
389
|
+
beforeEach(() => {
|
|
390
|
+
_state = {
|
|
391
|
+
name: "resolve",
|
|
392
|
+
resolve: {
|
|
393
|
+
user: function () {
|
|
394
|
+
return $timeout(() => {
|
|
395
|
+
return "joeschmoe";
|
|
396
|
+
}, 100);
|
|
397
|
+
},
|
|
396
398
|
},
|
|
397
|
-
}
|
|
398
|
-
};
|
|
399
|
+
};
|
|
400
|
+
});
|
|
399
401
|
|
|
400
402
|
it("should put the resolved data on the controllerAs", async () => {
|
|
401
403
|
const state = Object.assign(_state, {
|
|
@@ -406,7 +408,7 @@ describe("uiView", () => {
|
|
|
406
408
|
},
|
|
407
409
|
});
|
|
408
410
|
$stateProvider.state(state);
|
|
409
|
-
elem.append($compile("<div><
|
|
411
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
410
412
|
|
|
411
413
|
await $state.transitionTo("resolve");
|
|
412
414
|
await wait(100);
|
|
@@ -425,7 +427,7 @@ describe("uiView", () => {
|
|
|
425
427
|
});
|
|
426
428
|
|
|
427
429
|
$stateProvider.state(state);
|
|
428
|
-
elem.append($compile("<div><
|
|
430
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
429
431
|
|
|
430
432
|
await $state.transitionTo("resolve");
|
|
431
433
|
await wait(100);
|
|
@@ -441,7 +443,7 @@ describe("uiView", () => {
|
|
|
441
443
|
template: "{{$resolve.user}}",
|
|
442
444
|
});
|
|
443
445
|
$stateProvider.state(state);
|
|
444
|
-
elem.append($compile("<div><
|
|
446
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
445
447
|
expect(elem.text()).toBe("");
|
|
446
448
|
|
|
447
449
|
await $state.transitionTo("resolve");
|
|
@@ -457,7 +459,7 @@ describe("uiView", () => {
|
|
|
457
459
|
controller: controller,
|
|
458
460
|
});
|
|
459
461
|
$stateProvider.state(state);
|
|
460
|
-
elem.append($compile("<div><
|
|
462
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
461
463
|
|
|
462
464
|
await $state.transitionTo("resolve");
|
|
463
465
|
await wait(100);
|
|
@@ -493,7 +495,7 @@ describe("uiView", () => {
|
|
|
493
495
|
template: "hi",
|
|
494
496
|
controllerAs: "vm",
|
|
495
497
|
});
|
|
496
|
-
elem.append($compile("<div><
|
|
498
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
497
499
|
await $state.transitionTo("onInit");
|
|
498
500
|
await wait(100);
|
|
499
501
|
|
|
@@ -501,10 +503,10 @@ describe("uiView", () => {
|
|
|
501
503
|
});
|
|
502
504
|
|
|
503
505
|
// TargetNode not found error
|
|
504
|
-
xit("should default the template to a <
|
|
506
|
+
xit("should default the template to a <ng-view>", async () => {
|
|
505
507
|
$stateProvider.state({ name: "abstract", abstract: true });
|
|
506
508
|
$stateProvider.state({ name: "abstract.foo", template: "hello" });
|
|
507
|
-
elem.append($compile("<div><
|
|
509
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
508
510
|
$state.transitionTo("abstract.foo");
|
|
509
511
|
await wait(100);
|
|
510
512
|
|
|
@@ -516,35 +518,35 @@ describe("uiView", () => {
|
|
|
516
518
|
it("should work with ngIf", async () => {
|
|
517
519
|
scope.someBoolean = false;
|
|
518
520
|
elem.append(
|
|
519
|
-
$compile('<div ng-if="someBoolean"><
|
|
521
|
+
$compile('<div ng-if="someBoolean"><ng-view></ng-view></div>')(scope),
|
|
520
522
|
);
|
|
521
523
|
|
|
522
524
|
$state.transitionTo(aState);
|
|
523
525
|
await wait(100);
|
|
524
526
|
|
|
525
|
-
// Verify there is no
|
|
526
|
-
expect(elem.find("
|
|
527
|
+
// Verify there is no ng-view in the DOM
|
|
528
|
+
expect(elem.find("ng-view").length).toBe(0);
|
|
527
529
|
|
|
528
|
-
// Turn on the div that holds the
|
|
530
|
+
// Turn on the div that holds the ng-view
|
|
529
531
|
scope.someBoolean = true;
|
|
530
532
|
scope.$digest();
|
|
531
533
|
|
|
532
|
-
// Verify that the
|
|
533
|
-
expect(elem.find("
|
|
534
|
+
// Verify that the ng-view is there and it has the correct content
|
|
535
|
+
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
534
536
|
|
|
535
|
-
// Turn off the
|
|
537
|
+
// Turn off the ng-view
|
|
536
538
|
scope.someBoolean = false;
|
|
537
539
|
scope.$digest();
|
|
538
540
|
|
|
539
|
-
// Verify there is no
|
|
540
|
-
expect(elem.find("
|
|
541
|
+
// Verify there is no ng-view in the DOM
|
|
542
|
+
expect(elem.find("ng-view").length).toBe(0);
|
|
541
543
|
|
|
542
|
-
// Turn on the div that holds the
|
|
544
|
+
// Turn on the div that holds the ng-view once again
|
|
543
545
|
scope.someBoolean = true;
|
|
544
546
|
scope.$digest();
|
|
545
547
|
|
|
546
|
-
// Verify that the
|
|
547
|
-
expect(elem.find("
|
|
548
|
+
// Verify that the ng-view is there and it has the correct content
|
|
549
|
+
expect(elem.find("ng-view").text()).toBe(aState.template);
|
|
548
550
|
});
|
|
549
551
|
|
|
550
552
|
it("should work with ngClass", async () => {
|
|
@@ -553,47 +555,47 @@ describe("uiView", () => {
|
|
|
553
555
|
scope.showClass = false;
|
|
554
556
|
elem.append(
|
|
555
557
|
$compile(
|
|
556
|
-
"<div><
|
|
558
|
+
"<div><ng-view ng-class=\"{'someClass': showClass}\"></ng-view></div>",
|
|
557
559
|
)(scope),
|
|
558
560
|
);
|
|
559
561
|
|
|
560
|
-
expect(classes(elem.find("
|
|
562
|
+
expect(classes(elem.find("ng-view"))).not.toContain("someClass");
|
|
561
563
|
|
|
562
564
|
scope.showClass = true;
|
|
563
565
|
scope.$digest();
|
|
564
566
|
|
|
565
|
-
expect(classes(elem.find("
|
|
567
|
+
expect(classes(elem.find("ng-view"))).toContain("someClass");
|
|
566
568
|
|
|
567
569
|
scope.showClass = false;
|
|
568
570
|
scope.$digest();
|
|
569
571
|
|
|
570
|
-
expect(classes(elem.find("
|
|
572
|
+
expect(classes(elem.find("ng-view"))).not.toContain("someClass");
|
|
571
573
|
});
|
|
572
574
|
|
|
573
575
|
describe("working with ngRepeat", () => {
|
|
574
|
-
it("should have correct number of
|
|
576
|
+
it("should have correct number of ngViews", async () => {
|
|
575
577
|
elem.append(
|
|
576
578
|
$compile(
|
|
577
|
-
'<div><
|
|
579
|
+
'<div><ng-view ng-repeat="view in views" name="{{view}}"></ng-view></div>',
|
|
578
580
|
)(scope),
|
|
579
581
|
);
|
|
580
582
|
|
|
581
583
|
// Should be no ui-views in DOM
|
|
582
|
-
expect(elem.find("
|
|
584
|
+
expect(elem.find("ng-view").length).toBe(0);
|
|
583
585
|
|
|
584
586
|
// Lets add 3
|
|
585
587
|
scope.views = ["view1", "view2", "view3"];
|
|
586
588
|
scope.$digest();
|
|
587
589
|
|
|
588
590
|
// Should be 3 ui-views in the DOM
|
|
589
|
-
expect(elem.find("
|
|
591
|
+
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
590
592
|
|
|
591
593
|
// Lets add one more - yay two-way binding
|
|
592
594
|
scope.views.push("view4");
|
|
593
595
|
scope.$digest();
|
|
594
596
|
|
|
595
597
|
// Should have 4 ui-views
|
|
596
|
-
expect(elem.find("
|
|
598
|
+
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
597
599
|
|
|
598
600
|
// Lets remove 2 ui-views from the DOM
|
|
599
601
|
scope.views.pop();
|
|
@@ -601,46 +603,46 @@ describe("uiView", () => {
|
|
|
601
603
|
scope.$digest();
|
|
602
604
|
|
|
603
605
|
// Should have 2 ui-views
|
|
604
|
-
expect(elem.find("
|
|
606
|
+
expect(elem.find("ng-view").length).toBe(scope.views.length);
|
|
605
607
|
});
|
|
606
608
|
|
|
607
609
|
it("should populate each view with content", async () => {
|
|
608
610
|
elem.append(
|
|
609
611
|
$compile(
|
|
610
|
-
'<div><
|
|
612
|
+
'<div><ng-view ng-repeat="view in views" name="{{view}}">defaultcontent</ng-view></div>',
|
|
611
613
|
)(scope),
|
|
612
614
|
);
|
|
613
615
|
|
|
614
616
|
$state.transitionTo(lState);
|
|
615
617
|
await wait(100);
|
|
616
618
|
|
|
617
|
-
expect(elem.find("
|
|
619
|
+
expect(elem.find("ng-view").length).toBe(0);
|
|
618
620
|
|
|
619
621
|
scope.views = ["view1", "view2"];
|
|
620
622
|
|
|
621
623
|
scope.$digest();
|
|
622
624
|
|
|
623
|
-
let
|
|
625
|
+
let ngViews = elem.find("ng-view");
|
|
624
626
|
|
|
625
|
-
expect(
|
|
626
|
-
expect(
|
|
627
|
-
expect(
|
|
627
|
+
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
628
|
+
expect(ngViews.eq(1).text()).toBe(lState.views.view2.template);
|
|
629
|
+
expect(ngViews.eq(2).length).toBe(0);
|
|
628
630
|
|
|
629
631
|
scope.views.push("view3");
|
|
630
632
|
scope.$digest();
|
|
631
633
|
|
|
632
|
-
|
|
634
|
+
ngViews = elem.find("ng-view");
|
|
633
635
|
|
|
634
|
-
expect(
|
|
635
|
-
expect(
|
|
636
|
-
expect(
|
|
636
|
+
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
637
|
+
expect(ngViews.eq(1).text()).toBe(lState.views.view2.template);
|
|
638
|
+
expect(ngViews.eq(2).text()).toBe(lState.views.view3.template);
|
|
637
639
|
});
|
|
638
640
|
|
|
639
|
-
it("should interpolate
|
|
641
|
+
it("should interpolate ng-view names", async () => {
|
|
640
642
|
elem.append(
|
|
641
643
|
$compile(
|
|
642
644
|
'<div ng-repeat="view in views">' +
|
|
643
|
-
'<
|
|
645
|
+
'<ng-view name="view{{$index + 1}}">hallo</ng-view>' +
|
|
644
646
|
"</div>",
|
|
645
647
|
)(scope),
|
|
646
648
|
);
|
|
@@ -648,26 +650,26 @@ describe("uiView", () => {
|
|
|
648
650
|
$state.transitionTo(lState);
|
|
649
651
|
await wait(100);
|
|
650
652
|
|
|
651
|
-
expect(elem.find("
|
|
653
|
+
expect(elem.find("ng-view").length).toBe(0);
|
|
652
654
|
|
|
653
655
|
scope.views = ["view1", "view2"];
|
|
654
656
|
|
|
655
657
|
scope.$digest();
|
|
656
658
|
|
|
657
|
-
let
|
|
659
|
+
let ngViews = elem.find("ng-view");
|
|
658
660
|
|
|
659
|
-
expect(
|
|
660
|
-
expect(
|
|
661
|
-
expect(
|
|
661
|
+
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
662
|
+
expect(ngViews.eq(1).text()).toBe(lState.views.view2.template);
|
|
663
|
+
expect(ngViews.eq(2).length).toBe(0);
|
|
662
664
|
|
|
663
665
|
scope.views.push("view3");
|
|
664
666
|
scope.$digest();
|
|
665
667
|
|
|
666
|
-
|
|
668
|
+
ngViews = elem.find("ng-view");
|
|
667
669
|
|
|
668
|
-
expect(
|
|
669
|
-
expect(
|
|
670
|
-
expect(
|
|
670
|
+
expect(ngViews.eq(0).text()).toBe(lState.views.view1.template);
|
|
671
|
+
expect(ngViews.eq(1).text()).toBe(lState.views.view2.template);
|
|
672
|
+
expect(ngViews.eq(2).text()).toBe(lState.views.view3.template);
|
|
671
673
|
});
|
|
672
674
|
});
|
|
673
675
|
});
|
|
@@ -677,7 +679,7 @@ describe("uiView", () => {
|
|
|
677
679
|
// let content = "Initial Content",
|
|
678
680
|
// animation;
|
|
679
681
|
// elem.append(
|
|
680
|
-
// $compile("<div><
|
|
682
|
+
// $compile("<div><ng-view>" + content + "</ng-view></div>")(scope),
|
|
681
683
|
// );
|
|
682
684
|
|
|
683
685
|
// // Enter Animation
|
|
@@ -720,11 +722,11 @@ describe("uiView", () => {
|
|
|
720
722
|
// animation;
|
|
721
723
|
// elem.append(
|
|
722
724
|
// $compile(
|
|
723
|
-
// "<div><
|
|
725
|
+
// "<div><ng-view ng-class=\"{'" +
|
|
724
726
|
// className +
|
|
725
727
|
// "': classOn}\">" +
|
|
726
728
|
// content +
|
|
727
|
-
// "</
|
|
729
|
+
// "</ng-view></div>",
|
|
728
730
|
// )(scope),
|
|
729
731
|
// );
|
|
730
732
|
// // Don't care about enter class
|
|
@@ -754,7 +756,7 @@ describe("uiView", () => {
|
|
|
754
756
|
// animation;
|
|
755
757
|
// elem.append(
|
|
756
758
|
// $compile(
|
|
757
|
-
// '<div><
|
|
759
|
+
// '<div><ng-view ng-if="shouldShow">' + content + "</ng-view></div>",
|
|
758
760
|
// )(scope),
|
|
759
761
|
// );
|
|
760
762
|
|
|
@@ -764,12 +766,12 @@ describe("uiView", () => {
|
|
|
764
766
|
// scope.shouldShow = true;
|
|
765
767
|
// scope.$digest();
|
|
766
768
|
|
|
767
|
-
// // $ViewDirective enter animation - Basically it's just the <!--
|
|
769
|
+
// // $ViewDirective enter animation - Basically it's just the <!-- ngView --> comment
|
|
768
770
|
// animation = $animate.queue.shift();
|
|
769
771
|
// expect(animation.event).toBe("enter");
|
|
770
772
|
// expect(animation.element.text()).toBe("");
|
|
771
773
|
|
|
772
|
-
// // $ViewDirectiveFill enter animation - The second
|
|
774
|
+
// // $ViewDirectiveFill enter animation - The second ngView directive that files in the content
|
|
773
775
|
// animation = $animate.queue.shift();
|
|
774
776
|
// expect(animation.event).toBe("enter");
|
|
775
777
|
// expect(animation.element.text()).toBe(content);
|
|
@@ -777,7 +779,7 @@ describe("uiView", () => {
|
|
|
777
779
|
// scope.shouldShow = false;
|
|
778
780
|
// scope.$digest();
|
|
779
781
|
|
|
780
|
-
// //
|
|
782
|
+
// // ngView leave animation
|
|
781
783
|
// animation = $animate.queue.shift();
|
|
782
784
|
// expect(animation.event).toBe("leave");
|
|
783
785
|
// expect(animation.element.text()).toBe(content);
|
|
@@ -799,7 +801,7 @@ describe("uiView", () => {
|
|
|
799
801
|
|
|
800
802
|
// const content = "Initial Content";
|
|
801
803
|
// elem.append(
|
|
802
|
-
// $compile("<div><
|
|
804
|
+
// $compile("<div><ng-view>" + content + "</ng-view></div>")(scope),
|
|
803
805
|
// );
|
|
804
806
|
// $state.transitionTo("n");
|
|
805
807
|
// await wait(100);
|
|
@@ -839,7 +841,7 @@ describe("UiView", () => {
|
|
|
839
841
|
$q,
|
|
840
842
|
$timeout,
|
|
841
843
|
$rootScope,
|
|
842
|
-
$
|
|
844
|
+
$ngViewScroll;
|
|
843
845
|
|
|
844
846
|
beforeEach(() => {
|
|
845
847
|
dealoc(document.getElementById("dummy"));
|
|
@@ -847,7 +849,7 @@ describe("UiView", () => {
|
|
|
847
849
|
publishExternalAPI();
|
|
848
850
|
log = "";
|
|
849
851
|
app = window.angular
|
|
850
|
-
.module("defaultModule", ["
|
|
852
|
+
.module("defaultModule", ["ng.router"])
|
|
851
853
|
.config((_$stateProvider_) => {
|
|
852
854
|
$stateProvider = _$stateProvider_;
|
|
853
855
|
$stateProvider
|
|
@@ -870,7 +872,7 @@ describe("UiView", () => {
|
|
|
870
872
|
_$timeout_,
|
|
871
873
|
_$rootScope_,
|
|
872
874
|
_$compile_,
|
|
873
|
-
_$
|
|
875
|
+
_$ngViewScroll_,
|
|
874
876
|
) => {
|
|
875
877
|
$rootScope = _$rootScope_;
|
|
876
878
|
scope = $rootScope.$new();
|
|
@@ -879,14 +881,14 @@ describe("UiView", () => {
|
|
|
879
881
|
$q = _$q_;
|
|
880
882
|
$timeout = _$timeout_;
|
|
881
883
|
elem = jqLite("<div>");
|
|
882
|
-
$
|
|
884
|
+
$ngViewScroll = _$ngViewScroll_;
|
|
883
885
|
},
|
|
884
886
|
);
|
|
885
887
|
});
|
|
886
888
|
|
|
887
889
|
// TODO targetNode not found
|
|
888
890
|
xit("shouldn't puke on weird nested view setups", async () => {
|
|
889
|
-
$compile('<div
|
|
891
|
+
$compile('<div ng-view="main"><div ng-view="content"></div></div>')(
|
|
890
892
|
$rootScope,
|
|
891
893
|
);
|
|
892
894
|
|
|
@@ -900,10 +902,10 @@ describe("UiView", () => {
|
|
|
900
902
|
it("should target weird nested view setups using the view's simple name", async () => {
|
|
901
903
|
const tpl = `
|
|
902
904
|
<div>
|
|
903
|
-
<div
|
|
905
|
+
<div ng-view="main">
|
|
904
906
|
MAIN-DEFAULT-
|
|
905
|
-
<div
|
|
906
|
-
<div
|
|
907
|
+
<div ng-view="content">
|
|
908
|
+
<div ng-view="nest"></div>
|
|
907
909
|
</div>
|
|
908
910
|
</div>
|
|
909
911
|
</div>
|
|
@@ -918,7 +920,7 @@ describe("UiView", () => {
|
|
|
918
920
|
});
|
|
919
921
|
});
|
|
920
922
|
|
|
921
|
-
describe("
|
|
923
|
+
describe("ngView transclusion", () => {
|
|
922
924
|
let scope, $compile, elem, $injector, $rootScope, $state;
|
|
923
925
|
|
|
924
926
|
beforeEach(() => {
|
|
@@ -926,7 +928,7 @@ describe("uiView transclusion", () => {
|
|
|
926
928
|
window.angular = new Angular();
|
|
927
929
|
publishExternalAPI();
|
|
928
930
|
window.angular
|
|
929
|
-
.module("defaultModule", ["
|
|
931
|
+
.module("defaultModule", ["ng.router"])
|
|
930
932
|
.directive("scopeObserver", () => {
|
|
931
933
|
return {
|
|
932
934
|
restrict: "E",
|
|
@@ -942,7 +944,7 @@ describe("uiView transclusion", () => {
|
|
|
942
944
|
$stateProvider
|
|
943
945
|
.state({
|
|
944
946
|
name: "a",
|
|
945
|
-
template: "<
|
|
947
|
+
template: "<ng-view><scope-observer></scope-observer></ng-view>",
|
|
946
948
|
})
|
|
947
949
|
.state({ name: "a.b", template: "anything" });
|
|
948
950
|
});
|
|
@@ -957,7 +959,7 @@ describe("uiView transclusion", () => {
|
|
|
957
959
|
_$timeout_,
|
|
958
960
|
_$rootScope_,
|
|
959
961
|
_$compile_,
|
|
960
|
-
_$
|
|
962
|
+
_$ngViewScroll_,
|
|
961
963
|
) => {
|
|
962
964
|
$rootScope = _$rootScope_;
|
|
963
965
|
scope = $rootScope.$new();
|
|
@@ -976,14 +978,14 @@ describe("uiView transclusion", () => {
|
|
|
976
978
|
scope.$on("directiveDestroyed", () => {
|
|
977
979
|
aliveCount--;
|
|
978
980
|
});
|
|
979
|
-
elem.append($compile("<div><
|
|
981
|
+
elem.append($compile("<div><ng-view></ng-view></div>")(scope));
|
|
980
982
|
$state.transitionTo("a.b");
|
|
981
983
|
await wait(100);
|
|
982
984
|
expect(aliveCount).toBe(0);
|
|
983
985
|
});
|
|
984
986
|
});
|
|
985
987
|
|
|
986
|
-
describe("
|
|
988
|
+
describe("ngView controllers or onEnter handlers", () => {
|
|
987
989
|
let el, template, scope, count, $rootScope, $compile, $state, elem;
|
|
988
990
|
|
|
989
991
|
beforeEach(() => {
|
|
@@ -991,7 +993,7 @@ describe("uiView controllers or onEnter handlers", () => {
|
|
|
991
993
|
window.angular = new Angular();
|
|
992
994
|
publishExternalAPI();
|
|
993
995
|
window.angular
|
|
994
|
-
.module("defaultModule", ["
|
|
996
|
+
.module("defaultModule", ["ng.router"])
|
|
995
997
|
.config(function ($stateProvider) {
|
|
996
998
|
count = 0;
|
|
997
999
|
$stateProvider
|
|
@@ -1003,14 +1005,14 @@ describe("uiView controllers or onEnter handlers", () => {
|
|
|
1003
1005
|
.state({
|
|
1004
1006
|
name: "A",
|
|
1005
1007
|
url: "/A",
|
|
1006
|
-
template: '<div class="A"
|
|
1008
|
+
template: '<div class="A" ng-view="fwd"></div>',
|
|
1007
1009
|
})
|
|
1008
1010
|
.state({
|
|
1009
1011
|
name: "A.fwd",
|
|
1010
1012
|
url: "/fwd",
|
|
1011
1013
|
views: {
|
|
1012
1014
|
fwd: {
|
|
1013
|
-
template: '<div class="fwd"
|
|
1015
|
+
template: '<div class="fwd" ng-view>',
|
|
1014
1016
|
controller: function ($state) {
|
|
1015
1017
|
if (count++ < 20 && $state.current.name == "A.fwd")
|
|
1016
1018
|
$state.go(".nest");
|
|
@@ -1036,7 +1038,7 @@ describe("uiView controllers or onEnter handlers", () => {
|
|
|
1036
1038
|
_$timeout_,
|
|
1037
1039
|
_$rootScope_,
|
|
1038
1040
|
_$compile_,
|
|
1039
|
-
_$
|
|
1041
|
+
_$ngViewScroll_,
|
|
1040
1042
|
) => {
|
|
1041
1043
|
$rootScope = _$rootScope_;
|
|
1042
1044
|
scope = $rootScope.$new();
|
|
@@ -1048,7 +1050,7 @@ describe("uiView controllers or onEnter handlers", () => {
|
|
|
1048
1050
|
});
|
|
1049
1051
|
|
|
1050
1052
|
it("should not go into an infinite loop when controller uses $state.go", async () => {
|
|
1051
|
-
el = jqLite("<div><
|
|
1053
|
+
el = jqLite("<div><ng-view></ng-view></div>");
|
|
1052
1054
|
template = $compile(el)($rootScope);
|
|
1053
1055
|
$rootScope.$digest();
|
|
1054
1056
|
|
|
@@ -1079,7 +1081,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1079
1081
|
window.angular = new Angular();
|
|
1080
1082
|
publishExternalAPI();
|
|
1081
1083
|
window.angular
|
|
1082
|
-
.module("defaultModule", ["
|
|
1084
|
+
.module("defaultModule", ["ng.router"])
|
|
1083
1085
|
.directive("ng12Directive", () => {
|
|
1084
1086
|
return {
|
|
1085
1087
|
restrict: "E",
|
|
@@ -1153,7 +1155,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1153
1155
|
},
|
|
1154
1156
|
template: `
|
|
1155
1157
|
<h1>parentCmp</h1>
|
|
1156
|
-
<
|
|
1158
|
+
<ng-view on-event="$ctrl.handleEvent(foo, bar)"></ng-view>
|
|
1157
1159
|
`,
|
|
1158
1160
|
})
|
|
1159
1161
|
.component("childEventComponent", {
|
|
@@ -1197,7 +1199,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1197
1199
|
$rootScope = _$rootScope_;
|
|
1198
1200
|
scope = $rootScope.$new();
|
|
1199
1201
|
log = "";
|
|
1200
|
-
el = jqLite("<div><
|
|
1202
|
+
el = jqLite("<div><ng-view></ng-view></div>");
|
|
1201
1203
|
svcs.$compile(el)(scope);
|
|
1202
1204
|
$templateCache = _$templateCache_;
|
|
1203
1205
|
},
|
|
@@ -1231,7 +1233,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1231
1233
|
await $state.transitionTo("cmp_tpl");
|
|
1232
1234
|
|
|
1233
1235
|
expect($state.current.name).toBe("cmp_tpl");
|
|
1234
|
-
expect(el[0].querySelector("
|
|
1236
|
+
expect(el[0].querySelector("ng-view").innerHTML).toEqual(
|
|
1235
1237
|
'x<ng12-directive data="$resolve.data">-DATA!-</ng12-directive>x',
|
|
1236
1238
|
);
|
|
1237
1239
|
});
|
|
@@ -1249,7 +1251,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1249
1251
|
await wait(100);
|
|
1250
1252
|
|
|
1251
1253
|
expect($state.current.name).toBe("cmp_tpl");
|
|
1252
|
-
expect(el[0].querySelector("
|
|
1254
|
+
expect(el[0].querySelector("ng-view").innerHTML).toEqual(
|
|
1253
1255
|
'x<ng13-directive data="$resolve.data">-DATA!-</ng13-directive>x',
|
|
1254
1256
|
);
|
|
1255
1257
|
});
|
|
@@ -1267,7 +1269,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1267
1269
|
await wait(100);
|
|
1268
1270
|
|
|
1269
1271
|
expect($state.current.name).toBe("cmp_tpl");
|
|
1270
|
-
expect(el[0].querySelector("
|
|
1272
|
+
expect(el[0].querySelector("ng-view").innerHTML).toEqual(
|
|
1271
1273
|
'x<ng-component data="$resolve.data">-DATA!-</ng-component>x',
|
|
1272
1274
|
);
|
|
1273
1275
|
});
|
|
@@ -1352,7 +1354,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1352
1354
|
$state.transitionTo("route2cmp");
|
|
1353
1355
|
await wait(100);
|
|
1354
1356
|
|
|
1355
|
-
const directiveEl = el[0].querySelector("div
|
|
1357
|
+
const directiveEl = el[0].querySelector("div ng-view ng12-directive");
|
|
1356
1358
|
expect(directiveEl).toBeDefined();
|
|
1357
1359
|
expect($state.current.name).toBe("route2cmp");
|
|
1358
1360
|
expect(el.text()).toBe("-DATA!-");
|
|
@@ -1378,7 +1380,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1378
1380
|
$state.transitionTo("route2cmp");
|
|
1379
1381
|
await wait(100);
|
|
1380
1382
|
|
|
1381
|
-
const directiveEl = el[0].querySelector("div
|
|
1383
|
+
const directiveEl = el[0].querySelector("div ng-view ng13-directive");
|
|
1382
1384
|
expect(directiveEl).toBeDefined();
|
|
1383
1385
|
expect($state.current.name).toBe("route2cmp");
|
|
1384
1386
|
expect(el.text()).toBe("-DATA!-");
|
|
@@ -1425,7 +1427,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1425
1427
|
$state.transitionTo("route2cmp");
|
|
1426
1428
|
await wait(100);
|
|
1427
1429
|
|
|
1428
|
-
const directiveEl = el[0].querySelector("div
|
|
1430
|
+
const directiveEl = el[0].querySelector("div ng-view ng-component");
|
|
1429
1431
|
expect(directiveEl).toBeDefined();
|
|
1430
1432
|
expect($state.current.name).toBe("route2cmp");
|
|
1431
1433
|
expect(el.text()).toBe("-DATA!-");
|
|
@@ -1575,14 +1577,14 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1575
1577
|
});
|
|
1576
1578
|
|
|
1577
1579
|
// Test for #3239
|
|
1578
|
-
it("should pass any bindings (wired from a parent component template via the
|
|
1580
|
+
it("should pass any bindings (wired from a parent component template via the ng-view) through to the child", async () => {
|
|
1579
1581
|
const $state = svcs.$state,
|
|
1580
1582
|
$q = svcs.$q;
|
|
1581
1583
|
|
|
1582
1584
|
$stateProvider.state({
|
|
1583
1585
|
name: "parent",
|
|
1584
1586
|
template:
|
|
1585
|
-
'<
|
|
1587
|
+
'<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
|
|
1586
1588
|
controller: function ($scope) {
|
|
1587
1589
|
$scope.data1w = "1w";
|
|
1588
1590
|
$scope.data2w = "2w";
|
|
@@ -1600,14 +1602,14 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1600
1602
|
});
|
|
1601
1603
|
|
|
1602
1604
|
// Test for #3239
|
|
1603
|
-
it("should prefer
|
|
1605
|
+
it("should prefer ng-view bindings over resolve data", async () => {
|
|
1604
1606
|
const $state = svcs.$state,
|
|
1605
1607
|
$q = svcs.$q;
|
|
1606
1608
|
|
|
1607
1609
|
$stateProvider.state({
|
|
1608
1610
|
name: "parent",
|
|
1609
1611
|
template:
|
|
1610
|
-
'<
|
|
1612
|
+
'<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
|
|
1611
1613
|
resolve: {
|
|
1612
1614
|
oneway: () => "asfasfd",
|
|
1613
1615
|
twoway: () => "asfasfd",
|
|
@@ -1630,14 +1632,14 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1630
1632
|
});
|
|
1631
1633
|
|
|
1632
1634
|
// Test for #3239
|
|
1633
|
-
it("should prefer
|
|
1635
|
+
it("should prefer ng-view bindings over resolve data unless a bindings exists", async () => {
|
|
1634
1636
|
const $state = svcs.$state,
|
|
1635
1637
|
$q = svcs.$q;
|
|
1636
1638
|
|
|
1637
1639
|
$stateProvider.state({
|
|
1638
1640
|
name: "parent",
|
|
1639
1641
|
template:
|
|
1640
|
-
'<
|
|
1642
|
+
'<ng-view oneway="data1w" twoway="data2w" attr="attrval"></ng-view>',
|
|
1641
1643
|
resolve: {
|
|
1642
1644
|
oneway: () => "asfasfd",
|
|
1643
1645
|
twoway: () => "asfasfd",
|
|
@@ -1661,7 +1663,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1661
1663
|
});
|
|
1662
1664
|
|
|
1663
1665
|
// Test for #3239
|
|
1664
|
-
it("should pass & bindings (wired from a parent component via the
|
|
1666
|
+
it("should pass & bindings (wired from a parent component via the ng-view) through to the child", async () => {
|
|
1665
1667
|
const $state = svcs.$state,
|
|
1666
1668
|
$q = svcs.$q;
|
|
1667
1669
|
$rootScope.log = [];
|
|
@@ -1768,7 +1770,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1768
1770
|
};
|
|
1769
1771
|
|
|
1770
1772
|
el = jqLite(
|
|
1771
|
-
'<div><div
|
|
1773
|
+
'<div><div ng-view="header"></div><div ng-view="content"</div>',
|
|
1772
1774
|
);
|
|
1773
1775
|
svcs.$compile(el)(scope);
|
|
1774
1776
|
});
|
|
@@ -1792,8 +1794,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1792
1794
|
$state.transitionTo("route2cmp");
|
|
1793
1795
|
await wait(100);
|
|
1794
1796
|
|
|
1795
|
-
const header = el[0].querySelector("[
|
|
1796
|
-
const content = el[0].querySelector("[
|
|
1797
|
+
const header = el[0].querySelector("[ng-view=header]");
|
|
1798
|
+
const content = el[0].querySelector("[ng-view=content]");
|
|
1797
1799
|
|
|
1798
1800
|
expect(header.textContent).toBe("#awesome#");
|
|
1799
1801
|
expect(content.textContent).toBe("-DATA!-");
|
|
@@ -1822,8 +1824,8 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1822
1824
|
$state.transitionTo("route2cmp");
|
|
1823
1825
|
await wait(100);
|
|
1824
1826
|
|
|
1825
|
-
const header = el[0].querySelector("[
|
|
1826
|
-
const content = el[0].querySelector("[
|
|
1827
|
+
const header = el[0].querySelector("[ng-view=header]");
|
|
1828
|
+
const content = el[0].querySelector("[ng-view=content]");
|
|
1827
1829
|
|
|
1828
1830
|
expect(header.textContent).toBe("#awesome#");
|
|
1829
1831
|
expect(content.textContent).toBe("-DATA!-");
|
|
@@ -1864,7 +1866,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1864
1866
|
$state.transitionTo("route2cmp");
|
|
1865
1867
|
await wait(100);
|
|
1866
1868
|
|
|
1867
|
-
const directiveEl = el[0].querySelector("div
|
|
1869
|
+
const directiveEl = el[0].querySelector("div ng-view ng12-directive");
|
|
1868
1870
|
expect(directiveEl).toBeDefined();
|
|
1869
1871
|
expect($state.current.name).toBe("route2cmp");
|
|
1870
1872
|
expect(el.text()).toBe("-DATA!-");
|
|
@@ -1897,7 +1899,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1897
1899
|
$state.transitionTo("route2cmp");
|
|
1898
1900
|
await wait(100);
|
|
1899
1901
|
|
|
1900
|
-
const directiveEl = el[0].querySelector("div
|
|
1902
|
+
const directiveEl = el[0].querySelector("div ng-view ng-component");
|
|
1901
1903
|
expect(directiveEl).toBeDefined();
|
|
1902
1904
|
expect($state.current.name).toBe("route2cmp");
|
|
1903
1905
|
expect(el.text()).toBe("-DATA!.DATA2!-");
|
|
@@ -1926,7 +1928,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1926
1928
|
await wait(100);
|
|
1927
1929
|
|
|
1928
1930
|
const directiveEl = el[0].querySelector(
|
|
1929
|
-
"div
|
|
1931
|
+
"div ng-view ng12-dynamic-directive",
|
|
1930
1932
|
);
|
|
1931
1933
|
expect(directiveEl).toBeDefined();
|
|
1932
1934
|
expect($state.current.name).toBe("ng12-dynamic-directive");
|
|
@@ -1954,7 +1956,7 @@ describe("angular 1.5+ style .component()", () => {
|
|
|
1954
1956
|
});
|
|
1955
1957
|
await wait(100);
|
|
1956
1958
|
|
|
1957
|
-
const directiveEl = el[0].querySelector("div
|
|
1959
|
+
const directiveEl = el[0].querySelector("div ng-view dynamic-component");
|
|
1958
1960
|
expect(directiveEl).toBeDefined();
|
|
1959
1961
|
expect($state.current.name).toBe("dynamicComponent");
|
|
1960
1962
|
expect(el.text().trim()).toBe("dynamicComponent");
|