@angular-wave/angular.ts 0.0.28 → 0.0.29
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular-ts.esm.js +1 -1
- package/dist/angular-ts.umd.js +1 -1
- package/index.html +6 -5
- package/package.json +1 -1
- package/src/router/common/trace.js +6 -6
- package/src/router/directives/state-directives.js +74 -74
- package/src/router/directives/view-directive.js +21 -21
- package/src/router/index.js +12 -12
- package/src/router/injectables.js +3 -3
- package/src/router/router.js +7 -6
- package/src/router/services.js +4 -8
- package/src/router/state/state-builder.js +1 -0
- package/src/router/state/state-registry.js +55 -2
- package/src/router/state/state-service.js +16 -25
- package/src/router/state/views.js +4 -4
- package/src/router/state-filters.js +0 -2
- package/src/router/state-provider.js +0 -2
- package/src/router/template-factory.js +4 -4
- package/src/router/transition/transition-service.js +2 -3
- package/src/router/url/url-router.js +4 -0
- package/src/router/view/view.js +65 -65
- package/src/services/browser.js +1 -5
- 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/state/interface.d.ts +6 -6
- package/types/router/core/state/stateRegistry.d.ts +1 -0
- package/types/router/core/state/stateService.d.ts +4 -4
- package/types/router/core/transition/interface.d.ts +1 -1
- package/types/router/core/view/interface.d.ts +2 -2
- package/types/router/core/view/view.d.ts +16 -16
- package/types/router/directives/viewDirective.d.ts +3 -3
- package/types/router/interface.d.ts +4 -4
- package/types/router/stateProvider.d.ts +3 -3
- package/types/router/statebuilders/views.d.ts +1 -1
- package/types/router/templateFactory.d.ts +2 -2
- package/types/router/viewScroll.d.ts +1 -1
package/src/router/view/view.js
CHANGED
|
@@ -29,7 +29,7 @@ export class ViewService {
|
|
|
29
29
|
* @param {number} $id
|
|
30
30
|
*/
|
|
31
31
|
constructor($id) {
|
|
32
|
-
this.
|
|
32
|
+
this._ngViews = [];
|
|
33
33
|
this._viewConfigs = [];
|
|
34
34
|
this._viewConfigFactories = {};
|
|
35
35
|
this._listeners = [];
|
|
@@ -37,8 +37,8 @@ export class ViewService {
|
|
|
37
37
|
_rootViewContext: this._rootViewContext.bind(this),
|
|
38
38
|
_viewConfigFactory: this._viewConfigFactory.bind(this),
|
|
39
39
|
_registeredUIView: (id) =>
|
|
40
|
-
find(this.
|
|
41
|
-
_registeredUIViews: () => this.
|
|
40
|
+
find(this._ngViews, (view) => `${$id}.${view.id}` === id),
|
|
41
|
+
_registeredUIViews: () => this._ngViews,
|
|
42
42
|
_activeViewConfigs: () => this._viewConfigs,
|
|
43
43
|
_onSync: (listener) => {
|
|
44
44
|
this._listeners.push(listener);
|
|
@@ -51,45 +51,45 @@ export class ViewService {
|
|
|
51
51
|
* Normalizes a view's name from a state.views configuration block.
|
|
52
52
|
*
|
|
53
53
|
* This should be used by a framework implementation to calculate the values for
|
|
54
|
-
* [[_ViewDeclaration.$
|
|
54
|
+
* [[_ViewDeclaration.$ngViewName]] and [[_ViewDeclaration.$ngViewContextAnchor]].
|
|
55
55
|
*
|
|
56
56
|
* @param context the context object (state declaration) that the view belongs to
|
|
57
57
|
* @param rawViewName the name of the view, as declared in the [[StateDeclaration.views]]
|
|
58
58
|
*
|
|
59
|
-
* @returns the normalized
|
|
59
|
+
* @returns the normalized ngViewName and ngViewContextAnchor that the view targets
|
|
60
60
|
*/
|
|
61
61
|
static normalizeUIViewTarget(context, rawViewName = "") {
|
|
62
62
|
// TODO: Validate incoming view name with a regexp to allow:
|
|
63
63
|
// ex: "view.name@foo.bar" , "^.^.view.name" , "view.name@^.^" , "" ,
|
|
64
64
|
// "@" , "$default@^" , "!$default.$default" , "!foo.bar"
|
|
65
65
|
const viewAtContext = rawViewName.split("@");
|
|
66
|
-
let
|
|
67
|
-
let
|
|
66
|
+
let ngViewName = viewAtContext[0] || "$default"; // default to unnamed view
|
|
67
|
+
let ngViewContextAnchor = isString(viewAtContext[1])
|
|
68
68
|
? viewAtContext[1]
|
|
69
69
|
: "^"; // default to parent context
|
|
70
70
|
// Handle relative view-name sugar syntax.
|
|
71
71
|
// Matches rawViewName "^.^.^.foo.bar" into array: ["^.^.^.foo.bar", "^.^.^", "foo.bar"],
|
|
72
|
-
const relativeViewNameSugar = /^(\^(?:\.\^)*)\.(.*$)/.exec(
|
|
72
|
+
const relativeViewNameSugar = /^(\^(?:\.\^)*)\.(.*$)/.exec(ngViewName);
|
|
73
73
|
if (relativeViewNameSugar) {
|
|
74
74
|
// Clobbers existing contextAnchor (rawViewName validation will fix this)
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
ngViewContextAnchor = relativeViewNameSugar[1]; // set anchor to "^.^.^"
|
|
76
|
+
ngViewName = relativeViewNameSugar[2]; // set view-name to "foo.bar"
|
|
77
77
|
}
|
|
78
|
-
if (
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
if (ngViewName.charAt(0) === "!") {
|
|
79
|
+
ngViewName = ngViewName.substr(1);
|
|
80
|
+
ngViewContextAnchor = ""; // target absolutely from root
|
|
81
81
|
}
|
|
82
82
|
// handle parent relative targeting "^.^.^"
|
|
83
83
|
const relativeMatch = /^(\^(?:\.\^)*)$/;
|
|
84
|
-
if (relativeMatch.exec(
|
|
85
|
-
const anchorState =
|
|
84
|
+
if (relativeMatch.exec(ngViewContextAnchor)) {
|
|
85
|
+
const anchorState = ngViewContextAnchor
|
|
86
86
|
.split(".")
|
|
87
87
|
.reduce((anchor, x) => anchor.parent, context);
|
|
88
|
-
|
|
89
|
-
} else if (
|
|
90
|
-
|
|
88
|
+
ngViewContextAnchor = anchorState.name;
|
|
89
|
+
} else if (ngViewContextAnchor === ".") {
|
|
90
|
+
ngViewContextAnchor = context.name;
|
|
91
91
|
}
|
|
92
|
-
return {
|
|
92
|
+
return { ngViewName, ngViewContextAnchor };
|
|
93
93
|
}
|
|
94
94
|
|
|
95
95
|
_rootViewContext(context) {
|
|
@@ -125,18 +125,18 @@ export class ViewService {
|
|
|
125
125
|
this._viewConfigs.push(viewConfig);
|
|
126
126
|
}
|
|
127
127
|
sync() {
|
|
128
|
-
const
|
|
128
|
+
const ngViewsByFqn = this._ngViews
|
|
129
129
|
.map((uiv) => [uiv.fqn, uiv])
|
|
130
130
|
.reduce(applyPairs, {});
|
|
131
|
-
// Return a weighted depth value for a
|
|
131
|
+
// Return a weighted depth value for a ngView.
|
|
132
132
|
// The depth is the nesting depth of ui-views (based on FQN; times 10,000)
|
|
133
|
-
// plus the depth of the state that is populating the
|
|
134
|
-
function
|
|
133
|
+
// plus the depth of the state that is populating the ngView
|
|
134
|
+
function ngViewDepth(ngView) {
|
|
135
135
|
const stateDepth = (context) =>
|
|
136
136
|
context && context.parent ? stateDepth(context.parent) + 1 : 1;
|
|
137
137
|
return (
|
|
138
|
-
|
|
139
|
-
stateDepth(
|
|
138
|
+
ngView.fqn.split(".").length * 10000 +
|
|
139
|
+
stateDepth(ngView.creationContext)
|
|
140
140
|
);
|
|
141
141
|
}
|
|
142
142
|
// Return the ViewConfig's context's depth in the context tree.
|
|
@@ -151,34 +151,34 @@ export class ViewService {
|
|
|
151
151
|
(depthFn, posNeg, left, right) =>
|
|
152
152
|
posNeg * (depthFn(left) - depthFn(right)),
|
|
153
153
|
);
|
|
154
|
-
const matchingConfigPair = (
|
|
154
|
+
const matchingConfigPair = (ngView) => {
|
|
155
155
|
const matchingConfigs = this._viewConfigs.filter(
|
|
156
|
-
ViewService.matches(
|
|
156
|
+
ViewService.matches(ngViewsByFqn, ngView),
|
|
157
157
|
);
|
|
158
158
|
if (matchingConfigs.length > 1) {
|
|
159
159
|
// This is OK. Child states can target a ui-view that the parent state also targets (the child wins)
|
|
160
160
|
// Sort by depth and return the match from the deepest child
|
|
161
|
-
// console.log(`Multiple matching view configs for ${
|
|
161
|
+
// console.log(`Multiple matching view configs for ${ngView.fqn}`, matchingConfigs);
|
|
162
162
|
matchingConfigs.sort(depthCompare(viewConfigDepth, -1)); // descending
|
|
163
163
|
}
|
|
164
|
-
return {
|
|
164
|
+
return { ngView, viewConfig: matchingConfigs[0] };
|
|
165
165
|
};
|
|
166
166
|
const configureUIView = (tuple) => {
|
|
167
167
|
// If a parent ui-view is reconfigured, it could destroy child ui-views.
|
|
168
|
-
// Before configuring a child ui-view, make sure it's still in the active
|
|
169
|
-
if (this.
|
|
170
|
-
tuple.
|
|
168
|
+
// Before configuring a child ui-view, make sure it's still in the active ngViews array.
|
|
169
|
+
if (this._ngViews.indexOf(tuple.ngView) !== -1)
|
|
170
|
+
tuple.ngView.configUpdated(tuple.viewConfig);
|
|
171
171
|
};
|
|
172
172
|
// Sort views by FQN and state depth. Process uiviews nearest the root first.
|
|
173
|
-
const
|
|
174
|
-
.sort(depthCompare(
|
|
173
|
+
const ngViewTuples = this._ngViews
|
|
174
|
+
.sort(depthCompare(ngViewDepth, 1))
|
|
175
175
|
.map(matchingConfigPair);
|
|
176
|
-
const matchedViewConfigs =
|
|
176
|
+
const matchedViewConfigs = ngViewTuples.map((tuple) => tuple.viewConfig);
|
|
177
177
|
const unmatchedConfigTuples = this._viewConfigs
|
|
178
178
|
.filter((config) => !inArray(matchedViewConfigs, config))
|
|
179
|
-
.map((viewConfig) => ({
|
|
180
|
-
|
|
181
|
-
const allTuples =
|
|
179
|
+
.map((viewConfig) => ({ ngView: undefined, viewConfig }));
|
|
180
|
+
ngViewTuples.forEach(configureUIView);
|
|
181
|
+
const allTuples = ngViewTuples.concat(unmatchedConfigTuples);
|
|
182
182
|
this._listeners.forEach((cb) => cb(allTuples));
|
|
183
183
|
trace.traceViewSync(allTuples);
|
|
184
184
|
}
|
|
@@ -194,29 +194,29 @@ export class ViewService {
|
|
|
194
194
|
* Note: There is no corresponding `deregisterUIView`.
|
|
195
195
|
* A `ui-view` should hang on to the return value of `registerUIView` and invoke it to deregister itself.
|
|
196
196
|
*
|
|
197
|
-
* @param
|
|
197
|
+
* @param ngView The metadata for a UIView
|
|
198
198
|
* @return a de-registration function used when the view is destroyed.
|
|
199
199
|
*/
|
|
200
|
-
registerUIView(
|
|
201
|
-
trace.traceViewServiceUIViewEvent("-> Registering",
|
|
202
|
-
const
|
|
200
|
+
registerUIView(ngView) {
|
|
201
|
+
trace.traceViewServiceUIViewEvent("-> Registering", ngView);
|
|
202
|
+
const ngViews = this._ngViews;
|
|
203
203
|
const fqnAndTypeMatches = (uiv) =>
|
|
204
|
-
uiv.fqn ===
|
|
205
|
-
if (
|
|
206
|
-
trace.traceViewServiceUIViewEvent("!!!! duplicate
|
|
207
|
-
|
|
204
|
+
uiv.fqn === ngView.fqn && uiv.$type === ngView.$type;
|
|
205
|
+
if (ngViews.filter(fqnAndTypeMatches).length)
|
|
206
|
+
trace.traceViewServiceUIViewEvent("!!!! duplicate ngView named:", ngView);
|
|
207
|
+
ngViews.push(ngView);
|
|
208
208
|
this.sync();
|
|
209
209
|
return () => {
|
|
210
|
-
const idx =
|
|
210
|
+
const idx = ngViews.indexOf(ngView);
|
|
211
211
|
if (idx === -1) {
|
|
212
212
|
trace.traceViewServiceUIViewEvent(
|
|
213
|
-
"Tried removing non-registered
|
|
214
|
-
|
|
213
|
+
"Tried removing non-registered ngView",
|
|
214
|
+
ngView,
|
|
215
215
|
);
|
|
216
216
|
return;
|
|
217
217
|
}
|
|
218
|
-
trace.traceViewServiceUIViewEvent("<- Deregistering",
|
|
219
|
-
removeFrom(
|
|
218
|
+
trace.traceViewServiceUIViewEvent("<- Deregistering", ngView);
|
|
219
|
+
removeFrom(ngViews)(ngView);
|
|
220
220
|
};
|
|
221
221
|
}
|
|
222
222
|
/**
|
|
@@ -225,7 +225,7 @@ export class ViewService {
|
|
|
225
225
|
* @return {Array} Returns an array of fully-qualified view names.
|
|
226
226
|
*/
|
|
227
227
|
available() {
|
|
228
|
-
return this.
|
|
228
|
+
return this._ngViews.map(prop("fqn"));
|
|
229
229
|
}
|
|
230
230
|
/**
|
|
231
231
|
* Returns the list of views on the page containing loaded content.
|
|
@@ -233,7 +233,7 @@ export class ViewService {
|
|
|
233
233
|
* @return {Array} Returns an array of fully-qualified view names.
|
|
234
234
|
*/
|
|
235
235
|
active() {
|
|
236
|
-
return this.
|
|
236
|
+
return this._ngViews.filter(prop("$config")).map(prop("name"));
|
|
237
237
|
}
|
|
238
238
|
}
|
|
239
239
|
/**
|
|
@@ -269,7 +269,7 @@ export class ViewService {
|
|
|
269
269
|
* </ui-view>
|
|
270
270
|
* </ui-view>
|
|
271
271
|
*
|
|
272
|
-
*
|
|
272
|
+
* ngViews: [
|
|
273
273
|
* { fqn: "$default", creationContext: { name: "" } },
|
|
274
274
|
* { fqn: "$default.foo", creationContext: { name: "A" } },
|
|
275
275
|
* { fqn: "$default.foo.$default", creationContext: { name: "A.B" } }
|
|
@@ -278,10 +278,10 @@ export class ViewService {
|
|
|
278
278
|
*
|
|
279
279
|
* These four view configs all match the ui-view with the fqn: "$default.foo.$default.bar":
|
|
280
280
|
*
|
|
281
|
-
* - ViewConfig1: {
|
|
282
|
-
* - ViewConfig2: {
|
|
283
|
-
* - ViewConfig3: {
|
|
284
|
-
* - ViewConfig4: {
|
|
281
|
+
* - ViewConfig1: { ngViewName: "bar", ngViewContextAnchor: "A.B.C" }
|
|
282
|
+
* - ViewConfig2: { ngViewName: "$default.bar", ngViewContextAnchor: "A.B" }
|
|
283
|
+
* - ViewConfig3: { ngViewName: "foo.$default.bar", ngViewContextAnchor: "A" }
|
|
284
|
+
* - ViewConfig4: { ngViewName: "$default.foo.$default.bar", ngViewContextAnchor: "" }
|
|
285
285
|
*
|
|
286
286
|
* Using ViewConfig3 as an example, it matches the ui-view with fqn "$default.foo.$default.bar" because:
|
|
287
287
|
* - The ViewConfig's segmented target name is: [ "foo", "$default", "bar" ]
|
|
@@ -293,13 +293,13 @@ export class ViewService {
|
|
|
293
293
|
*
|
|
294
294
|
* @internal
|
|
295
295
|
*/
|
|
296
|
-
ViewService.matches = (
|
|
296
|
+
ViewService.matches = (ngViewsByFqn, ngView) => (viewConfig) => {
|
|
297
297
|
// Don't supply an ng1 ui-view with an ng2 ViewConfig, etc
|
|
298
|
-
if (
|
|
299
|
-
// Split names apart from both viewConfig and
|
|
298
|
+
if (ngView.$type !== viewConfig.viewDecl.$type) return false;
|
|
299
|
+
// Split names apart from both viewConfig and ngView into segments
|
|
300
300
|
const vc = viewConfig.viewDecl;
|
|
301
|
-
const vcSegments = vc.$
|
|
302
|
-
const uivSegments =
|
|
301
|
+
const vcSegments = vc.$ngViewName.split(".");
|
|
302
|
+
const uivSegments = ngView.fqn.split(".");
|
|
303
303
|
// Check if the tails of the segment arrays match. ex, these arrays' tails match:
|
|
304
304
|
// vc: ["foo", "bar"], uiv fqn: ["$default", "foo", "bar"]
|
|
305
305
|
if (!equals(vcSegments, uivSegments.slice(0 - vcSegments.length)))
|
|
@@ -308,6 +308,6 @@ ViewService.matches = (uiViewsByFqn, uiView) => (viewConfig) => {
|
|
|
308
308
|
// ["$default", "foo"].join(".") == "$default.foo", does the ui-view $default.foo context match?
|
|
309
309
|
const negOffset = 1 - vcSegments.length || undefined;
|
|
310
310
|
const fqnToFirstSegment = uivSegments.slice(0, negOffset).join(".");
|
|
311
|
-
const
|
|
312
|
-
return vc.$
|
|
311
|
+
const ngViewContext = ngViewsByFqn[fqnToFirstSegment].creationContext;
|
|
312
|
+
return vc.$ngViewContextAnchor === (ngViewContext && ngViewContext.name);
|
|
313
313
|
};
|
package/src/services/browser.js
CHANGED
|
@@ -102,11 +102,7 @@ export function Browser($log, $$taskTrackerFactory) {
|
|
|
102
102
|
// lastBrowserUrl && stripHash(lastBrowserUrl) === stripHash(url);
|
|
103
103
|
lastBrowserUrl = url;
|
|
104
104
|
lastHistoryState = state;
|
|
105
|
-
|
|
106
|
-
// due to a bug in IE10/IE11 which leads
|
|
107
|
-
// to not firing a `hashchange` nor `popstate` event
|
|
108
|
-
// in some cases (see #9143).
|
|
109
|
-
history[replace ? "replaceState" : "pushState"](state, "", url);
|
|
105
|
+
history.pushState(state, "", url);
|
|
110
106
|
cacheState();
|
|
111
107
|
return self;
|
|
112
108
|
// getter
|
package/test/core/pubsub.spec.js
CHANGED
|
@@ -311,4 +311,77 @@ describe("PubSub", function () {
|
|
|
311
311
|
}, 0);
|
|
312
312
|
}, 0);
|
|
313
313
|
});
|
|
314
|
+
|
|
315
|
+
describe("publish", () => {
|
|
316
|
+
let context, fooCalled, barCalled, SOME_TOPIC;
|
|
317
|
+
|
|
318
|
+
beforeEach(function () {
|
|
319
|
+
context = {};
|
|
320
|
+
fooCalled = false;
|
|
321
|
+
barCalled = false;
|
|
322
|
+
SOME_TOPIC = "someTopic";
|
|
323
|
+
});
|
|
324
|
+
|
|
325
|
+
function foo(record) {
|
|
326
|
+
fooCalled = true;
|
|
327
|
+
expect(record.x).toBe("x");
|
|
328
|
+
expect(record.y).toBe("y");
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
function bar(record) {
|
|
332
|
+
barCalled = true;
|
|
333
|
+
expect(this).toBe(context);
|
|
334
|
+
expect(record.x).toBe("x");
|
|
335
|
+
expect(record.y).toBe("y");
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
it("should call subscribed functions on publish", function () {
|
|
339
|
+
pubsub.subscribe(SOME_TOPIC, foo);
|
|
340
|
+
pubsub.subscribe(SOME_TOPIC, bar, context);
|
|
341
|
+
|
|
342
|
+
expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
|
|
343
|
+
expect(fooCalled).toBe(true, "foo() must have been called");
|
|
344
|
+
expect(barCalled).toBe(true, "bar() must have been called");
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("should not call unsubscribed functions on publish", function () {
|
|
348
|
+
pubsub.subscribe(SOME_TOPIC, foo);
|
|
349
|
+
pubsub.subscribe(SOME_TOPIC, bar, context);
|
|
350
|
+
|
|
351
|
+
pubsub.publish(SOME_TOPIC, { x: "x", y: "y" });
|
|
352
|
+
fooCalled = false;
|
|
353
|
+
barCalled = false;
|
|
354
|
+
expect(pubsub.unsubscribe(SOME_TOPIC, foo)).toBe(true);
|
|
355
|
+
|
|
356
|
+
expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
|
|
357
|
+
expect(fooCalled).toBe(false, "foo() must not have been called");
|
|
358
|
+
expect(barCalled).toBe(true, "bar() must have been called");
|
|
359
|
+
});
|
|
360
|
+
|
|
361
|
+
it("should only call functions subscribed to the correct topic", function () {
|
|
362
|
+
pubsub.subscribe(SOME_TOPIC, bar, context);
|
|
363
|
+
pubsub.subscribe("differentTopic", foo);
|
|
364
|
+
|
|
365
|
+
pubsub.publish(SOME_TOPIC, { x: "x", y: "y" });
|
|
366
|
+
fooCalled = false;
|
|
367
|
+
barCalled = false;
|
|
368
|
+
|
|
369
|
+
expect(pubsub.publish(SOME_TOPIC, { x: "x", y: "y" })).toBe(true);
|
|
370
|
+
expect(fooCalled).toBe(false, "foo() must not have been called");
|
|
371
|
+
expect(barCalled).toBe(true, "bar() must have been called");
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
it("should trigger functions if not arguments are provided", function () {
|
|
375
|
+
let called = false;
|
|
376
|
+
pubsub.subscribe(SOME_TOPIC, () => {
|
|
377
|
+
called = true;
|
|
378
|
+
0;
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
pubsub.publish(SOME_TOPIC);
|
|
382
|
+
|
|
383
|
+
expect(pubsub.publish(SOME_TOPIC)).toBe(true);
|
|
384
|
+
expect(called).toBeTrue();
|
|
385
|
+
});
|
|
386
|
+
});
|
|
314
387
|
});
|
package/test/module-test.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<script type="module" src="../src/index.js"></script>
|
|
6
6
|
<script>
|
|
7
7
|
document.addEventListener("DOMContentLoaded", () => {
|
|
8
|
-
var myApp = window.angular.module("test", ["
|
|
8
|
+
var myApp = window.angular.module("test", ["ng.router"]);
|
|
9
9
|
myApp
|
|
10
10
|
.config(function ($stateProvider) {
|
|
11
11
|
$stateProvider
|
|
@@ -20,19 +20,19 @@
|
|
|
20
20
|
name: "contacts",
|
|
21
21
|
url: "/contacts",
|
|
22
22
|
template:
|
|
23
|
-
'<a
|
|
23
|
+
'<a ng-sref=".item({ id: 5 })" class="item">Person</a> <ng-view></ng-view>',
|
|
24
24
|
})
|
|
25
25
|
.state({
|
|
26
26
|
name: "contacts.item",
|
|
27
27
|
url: "/{id:int}",
|
|
28
28
|
template:
|
|
29
|
-
'<a
|
|
29
|
+
'<a ng-sref=".detail" class="item-detail">Detail</a> | <a ng-sref="^" class="item-parent">Parent</a> | <ng-view></ng-view>',
|
|
30
30
|
})
|
|
31
31
|
.state({
|
|
32
32
|
name: "contacts.item.detail",
|
|
33
33
|
url: "/{id}",
|
|
34
34
|
template:
|
|
35
|
-
'<div class="title">Detail</div> | <a
|
|
35
|
+
'<div class="title">Detail</div> | <a ng-sref="^" class="item-parent2">Item</a>',
|
|
36
36
|
});
|
|
37
37
|
})
|
|
38
38
|
.controller(
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
<body ng-app="test">
|
|
53
53
|
<div ng-controller="TestController as $ctrl">
|
|
54
54
|
{{$ctrl.test}}
|
|
55
|
-
<a
|
|
55
|
+
<a ng-sref="contacts.item.detail({ id: contact.id })">Details</a>
|
|
56
56
|
</div>
|
|
57
57
|
</body>
|
|
58
58
|
</html>
|
package/test/original-test.html
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
<script src="//unpkg.com/@uirouter/angularjs/release/angular-ui-router.js"></script>
|
|
7
7
|
<script>
|
|
8
|
-
var myApp = angular.module("test", ["
|
|
8
|
+
var myApp = angular.module("test", ["ng.router"]);
|
|
9
9
|
|
|
10
10
|
myApp.config(function ($stateProvider) {
|
|
11
11
|
var helloState = {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
</script>
|
|
27
27
|
</head>
|
|
28
28
|
<body ng-app="test">
|
|
29
|
-
<a
|
|
30
|
-
<
|
|
29
|
+
<a ng-sref="hello" ng-sref-active="active">Hello</a>
|
|
30
|
+
<ng-view></ng-view>
|
|
31
31
|
{{ 2 + 2}}
|
|
32
32
|
</body>
|
|
33
33
|
</html>
|
|
@@ -9,7 +9,7 @@ describe("router services", () => {
|
|
|
9
9
|
beforeEach(() => {
|
|
10
10
|
window.angular = new Angular();
|
|
11
11
|
publishExternalAPI();
|
|
12
|
-
let module = window.angular.module("defaultModule", ["
|
|
12
|
+
let module = window.angular.module("defaultModule", ["ng.router"]);
|
|
13
13
|
module.config(
|
|
14
14
|
(
|
|
15
15
|
_$routerProvider_,
|