@angular-wave/angular.ts 0.0.26 → 0.0.27
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 +3 -3
- package/package.json +1 -1
- package/src/router/globals.js +0 -5
- package/src/router/params/param-types.js +0 -3
- package/src/router/router.js +5 -53
- package/src/router/services.js +2 -4
- package/src/router/state/state-queue-manager.js +0 -3
- package/src/router/state/state-registry.js +0 -5
- package/src/router/state/state-service.js +0 -4
- package/src/router/transition/transition-hook.js +1 -8
- package/src/router/transition/transition-service.js +0 -12
- package/src/router/url/url-config.js +7 -7
- package/src/router/url/url-router.js +1 -1
- package/src/router/url/url-rules.js +0 -4
- package/src/router/url/url-service.js +113 -80
- package/test/core/interval.spec.js +1 -1
- package/test/router/state-directives.spec.js +72 -72
- package/test/router/state.spec.js +5 -5
- package/test/router/template-factory.spec.js +2 -2
- package/test/router/view-directive.spec.js +65 -65
- package/test/router/view-hook.spec.js +11 -11
- package/test/router/view-scroll.spec.js +2 -2
- package/test/router/view.spec.js +1 -1
- package/src/router/location-services.js +0 -67
package/index.html
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
|
|
17
17
|
<!-- <script src="dist/angular-ts.umd.js"></script> -->
|
|
18
18
|
<!-- include spec files here... -->
|
|
19
|
-
|
|
19
|
+
<!--
|
|
20
20
|
<script type="module" src="test/directive/boolean.spec.js"></script>
|
|
21
21
|
<script type="module" src="test/directive/form.spec.js"></script>
|
|
22
22
|
<script type="module" src="test/directive/input.spec.js"></script>
|
|
@@ -95,14 +95,14 @@
|
|
|
95
95
|
<script type="module" src="test/shared/common.spec.js"></script>
|
|
96
96
|
<script type="module" src="test/shared/hof.spec.js"></script>
|
|
97
97
|
<script type="module" src="test/shared/strings.spec.js"></script>
|
|
98
|
-
<script type="module" src="test/shared/utils.spec.js"></script>
|
|
98
|
+
<script type="module" src="test/shared/utils.spec.js"></script> -->
|
|
99
99
|
|
|
100
100
|
<!-- Router specs-->
|
|
101
101
|
<script type="module" src="test/router/glob.spec.js"></script>
|
|
102
102
|
<script type="module" src="test/router/services.spec.js"></script>
|
|
103
103
|
<script type="module" src="test/router/state-directives.spec.js"></script>
|
|
104
104
|
<script type="module" src="test/router/state-filter.spec.js"></script>
|
|
105
|
-
|
|
105
|
+
<script type="module" src="test/router/state.spec.js"></script>
|
|
106
106
|
<script type="module" src="test/router/template-factory.spec.js"></script>
|
|
107
107
|
<script type="module" src="test/router/url-matcher-factory.spec.js"></script>
|
|
108
108
|
<script type="module" src="test/router/view-directive.spec.js"></script>
|
package/package.json
CHANGED
package/src/router/globals.js
CHANGED
package/src/router/router.js
CHANGED
|
@@ -5,8 +5,6 @@ import { ViewService } from "./view/view";
|
|
|
5
5
|
import { StateRegistry } from "./state/state-registry";
|
|
6
6
|
import { StateService } from "./state/state-service";
|
|
7
7
|
import { UIRouterGlobals } from "./globals";
|
|
8
|
-
import { removeFrom } from "../shared/common";
|
|
9
|
-
import { isFunction } from "../shared/utils";
|
|
10
8
|
import { UrlService } from "./url/url-service";
|
|
11
9
|
import { trace } from "./common/trace";
|
|
12
10
|
|
|
@@ -26,18 +24,14 @@ export class UIRouter {
|
|
|
26
24
|
/**
|
|
27
25
|
* Creates a new `UIRouter` object
|
|
28
26
|
*
|
|
29
|
-
* @param {
|
|
27
|
+
* @param {angular.ILocationProvider} $locationProvider
|
|
30
28
|
*/
|
|
31
|
-
constructor(
|
|
32
|
-
/**
|
|
33
|
-
* @type {import('./location-services').Ng1LocationServices}
|
|
34
|
-
*/
|
|
35
|
-
this.locationService = locationService;
|
|
29
|
+
constructor($locationProvider) {
|
|
36
30
|
/** @type {number} */ this.$id = routerId++;
|
|
37
|
-
|
|
38
|
-
this._disposables = [];
|
|
31
|
+
|
|
39
32
|
/** Enable/disable tracing to the javascript console */
|
|
40
33
|
this.trace = trace;
|
|
34
|
+
this.$locationProvider = $locationProvider;
|
|
41
35
|
/** Provides services related to ui-view synchronization */
|
|
42
36
|
this.viewService = new ViewService(this);
|
|
43
37
|
/** @type {UIRouterGlobals} An object that contains global router state, such as the current state and params */
|
|
@@ -55,7 +49,7 @@ export class UIRouter {
|
|
|
55
49
|
*/
|
|
56
50
|
this.urlRouter = new UrlRouter(this);
|
|
57
51
|
/** Provides services related to the URL */
|
|
58
|
-
this.urlService = new UrlService(this);
|
|
52
|
+
this.urlService = new UrlService(this, $locationProvider);
|
|
59
53
|
/** Provides a registry for states, and related registration services */
|
|
60
54
|
this.stateRegistry = new StateRegistry(this);
|
|
61
55
|
/** Provides services related to states */
|
|
@@ -65,47 +59,6 @@ export class UIRouter {
|
|
|
65
59
|
this.viewService._pluginapi._rootViewContext(this.stateRegistry.root());
|
|
66
60
|
this.globals.$current = this.stateRegistry.root();
|
|
67
61
|
this.globals.current = this.globals.$current.self;
|
|
68
|
-
this.disposable(this.globals);
|
|
69
|
-
this.disposable(this.stateService);
|
|
70
|
-
this.disposable(this.stateRegistry);
|
|
71
|
-
this.disposable(this.transitionService);
|
|
72
|
-
this.disposable(this.urlService);
|
|
73
|
-
this.disposable(locationService);
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Registers an object to be notified when the router is disposed
|
|
78
|
-
* @param {Disposable} disposable
|
|
79
|
-
* @returns {void}
|
|
80
|
-
*/
|
|
81
|
-
disposable(disposable) {
|
|
82
|
-
this._disposables.push(disposable);
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Disposes this router instance
|
|
86
|
-
*
|
|
87
|
-
* When called, clears resources retained by the router by calling `dispose(this)` on all
|
|
88
|
-
* registered [[disposable]] objects.
|
|
89
|
-
*
|
|
90
|
-
* Or, if a `disposable` object is provided, calls `dispose(this)` on that object only.
|
|
91
|
-
*
|
|
92
|
-
* @internal
|
|
93
|
-
* @param disposable (optional) the disposable to dispose
|
|
94
|
-
*/
|
|
95
|
-
dispose(disposable) {
|
|
96
|
-
if (disposable && isFunction(disposable.dispose)) {
|
|
97
|
-
disposable.dispose(this);
|
|
98
|
-
return undefined;
|
|
99
|
-
}
|
|
100
|
-
this._disposed = true;
|
|
101
|
-
this._disposables.slice().forEach((d) => {
|
|
102
|
-
try {
|
|
103
|
-
typeof d.dispose === "function" && d.dispose(this);
|
|
104
|
-
removeFrom(this._disposables, d);
|
|
105
|
-
} catch (ignored) {
|
|
106
|
-
/* empty */
|
|
107
|
-
}
|
|
108
|
-
});
|
|
109
62
|
}
|
|
110
63
|
|
|
111
64
|
/**
|
|
@@ -167,7 +120,6 @@ export class UIRouter {
|
|
|
167
120
|
throw new Error(
|
|
168
121
|
"Required property `name` missing on plugin: " + pluginInstance,
|
|
169
122
|
);
|
|
170
|
-
this._disposables.push(pluginInstance);
|
|
171
123
|
return (this._plugins[pluginInstance.name] = pluginInstance);
|
|
172
124
|
}
|
|
173
125
|
getPlugin(pluginName) {
|
package/src/router/services.js
CHANGED
|
@@ -16,7 +16,6 @@ import { UIRouter } from "./router";
|
|
|
16
16
|
import { ng1ViewsBuilder, getNg1ViewConfigFactory } from "./state/views";
|
|
17
17
|
|
|
18
18
|
import { StateProvider } from "./state-provider";
|
|
19
|
-
import { Ng1LocationServices } from "./location-services";
|
|
20
19
|
import { ResolveContext } from "./resolve/resolve-context";
|
|
21
20
|
|
|
22
21
|
/** @type {angular.UIRouter}} */
|
|
@@ -24,9 +23,8 @@ export let router = null;
|
|
|
24
23
|
$routerProvider.$inject = ["$locationProvider"];
|
|
25
24
|
/** This angular 1 provider instantiates a Router and exposes its services via the angular injector */
|
|
26
25
|
export function $routerProvider($locationProvider) {
|
|
27
|
-
const ng1LocationService = new Ng1LocationServices($locationProvider);
|
|
28
26
|
// Create a new instance of the Router when the $routerProvider is initialized
|
|
29
|
-
router = this.router = new UIRouter(
|
|
27
|
+
router = this.router = new UIRouter($locationProvider);
|
|
30
28
|
router.stateProvider = new StateProvider(
|
|
31
29
|
router.stateRegistry,
|
|
32
30
|
router.stateService,
|
|
@@ -69,7 +67,7 @@ export function $routerProvider($locationProvider) {
|
|
|
69
67
|
router["$get"] = $get;
|
|
70
68
|
$get.$inject = ["$location", "$browser", "$rootScope"];
|
|
71
69
|
function $get($location, $browser, $rootScope) {
|
|
72
|
-
|
|
70
|
+
router.urlService._runtimeServices($rootScope, $location, $browser);
|
|
73
71
|
return router;
|
|
74
72
|
}
|
|
75
73
|
return router;
|
|
@@ -39,11 +39,6 @@ export class StateRegistry {
|
|
|
39
39
|
_root.navigable = null;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
dispose() {
|
|
43
|
-
this.stateQueue.dispose();
|
|
44
|
-
this.listeners = [];
|
|
45
|
-
this.get().forEach((state) => this.get(state) && this.deregister(state));
|
|
46
|
-
}
|
|
47
42
|
/**
|
|
48
43
|
* Listen for a State Registry events
|
|
49
44
|
*
|
|
@@ -142,16 +142,9 @@ export class TransitionHook {
|
|
|
142
142
|
}
|
|
143
143
|
/**
|
|
144
144
|
* Return a Rejection promise if the transition is no longer current due
|
|
145
|
-
*
|
|
145
|
+
* a new transition has started and superseded this one.
|
|
146
146
|
*/
|
|
147
147
|
getNotCurrentRejection() {
|
|
148
|
-
const router = this.transition.router;
|
|
149
|
-
// The router is stopped
|
|
150
|
-
if (router._disposed) {
|
|
151
|
-
return Rejection.aborted(
|
|
152
|
-
`UIRouter instance #${router.$id} has been stopped (disposed)`,
|
|
153
|
-
).toPromise();
|
|
154
|
-
}
|
|
155
148
|
if (this.transition._aborted) {
|
|
156
149
|
return Rejection.aborted().toPromise();
|
|
157
150
|
}
|
|
@@ -110,18 +110,6 @@ export class TransitionService {
|
|
|
110
110
|
* @returns a function which deregisters the hook.
|
|
111
111
|
*/
|
|
112
112
|
|
|
113
|
-
/**
|
|
114
|
-
* dispose
|
|
115
|
-
* @internal
|
|
116
|
-
*/
|
|
117
|
-
dispose() {
|
|
118
|
-
Object.values(this._registeredHooks).forEach((hooksArray) =>
|
|
119
|
-
hooksArray.forEach((hook) => {
|
|
120
|
-
hook._deregistered = true;
|
|
121
|
-
removeFrom(hooksArray, hook);
|
|
122
|
-
}),
|
|
123
|
-
);
|
|
124
|
-
}
|
|
125
113
|
/**
|
|
126
114
|
* Creates a new [[Transition]] object
|
|
127
115
|
*
|
|
@@ -30,14 +30,14 @@ export class UrlConfig {
|
|
|
30
30
|
this._isStrictMode = true;
|
|
31
31
|
/** @type {boolean} */
|
|
32
32
|
this._defaultSquashPolicy = false;
|
|
33
|
-
|
|
33
|
+
|
|
34
34
|
// Delegate these calls to the current LocationConfig implementation
|
|
35
35
|
/**
|
|
36
36
|
* Gets the base Href, e.g., `http://localhost/approot/`
|
|
37
37
|
*
|
|
38
38
|
* @return the application's base href
|
|
39
39
|
*/
|
|
40
|
-
this.baseHref = () => this.router.
|
|
40
|
+
this.baseHref = () => this.router.urlService.baseHref();
|
|
41
41
|
/**
|
|
42
42
|
* Gets or sets the hashPrefix
|
|
43
43
|
*
|
|
@@ -48,31 +48,31 @@ export class UrlConfig {
|
|
|
48
48
|
* @return the hash prefix
|
|
49
49
|
*/
|
|
50
50
|
this.hashPrefix = (newprefix) =>
|
|
51
|
-
this.router
|
|
51
|
+
this.router.$locationProvider.hashPrefix(newprefix);
|
|
52
52
|
/**
|
|
53
53
|
* Gets the host, e.g., `localhost`
|
|
54
54
|
*
|
|
55
55
|
* @return {string} the protocol
|
|
56
56
|
*/
|
|
57
|
-
this.host = () => this.router.
|
|
57
|
+
this.host = () => this.router.urlService.$location.host();
|
|
58
58
|
/**
|
|
59
59
|
* Returns true when running in pushstate mode
|
|
60
60
|
*
|
|
61
61
|
* @return {boolean} true when running in html5 mode (pushstate mode).
|
|
62
62
|
*/
|
|
63
|
-
this.html5Mode = () => this.router.
|
|
63
|
+
this.html5Mode = () => this.router.urlService.html5Mode();
|
|
64
64
|
/**
|
|
65
65
|
* Gets the port, e.g., `80`
|
|
66
66
|
*
|
|
67
67
|
* @return {number} the port number
|
|
68
68
|
*/
|
|
69
|
-
this.port = () => this.router.
|
|
69
|
+
this.port = () => this.router.urlService.$location.port();
|
|
70
70
|
/**
|
|
71
71
|
* Gets the protocol, e.g., `http`
|
|
72
72
|
*
|
|
73
73
|
* @return {string} the protocol
|
|
74
74
|
*/
|
|
75
|
-
this.protocol = () => this.router.
|
|
75
|
+
this.protocol = () => this.router.urlService.$location.protocol();
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Defines whether URL matching should be case sensitive (the default behavior), or not.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { isString } from "../../shared/utils";
|
|
1
|
+
import { isDefined, isObject, isString } from "../../shared/utils";
|
|
2
2
|
import { is, pattern } from "../../shared/hof";
|
|
3
3
|
import { UrlRules } from "./url-rules";
|
|
4
4
|
import { UrlConfig } from "./url-config";
|
|
5
5
|
import { TargetState } from "../state/target-state";
|
|
6
|
+
import { removeFrom } from "../../shared/common";
|
|
6
7
|
/**
|
|
7
8
|
* API for URL management
|
|
8
9
|
*/
|
|
@@ -10,13 +11,16 @@ export class UrlService {
|
|
|
10
11
|
/**
|
|
11
12
|
*
|
|
12
13
|
* @param {import('../router').UIRouter} router
|
|
14
|
+
* @param {angular.ILocationProvider} $locationProvider
|
|
13
15
|
*/
|
|
14
|
-
constructor(router) {
|
|
16
|
+
constructor(router, $locationProvider) {
|
|
15
17
|
/**
|
|
16
18
|
* @type {import('../router').UIRouter}
|
|
17
19
|
*/
|
|
18
20
|
this.router = router;
|
|
19
21
|
|
|
22
|
+
this.$locationProvider = $locationProvider;
|
|
23
|
+
|
|
20
24
|
/** @type {boolean} */
|
|
21
25
|
this.interceptDeferred = false;
|
|
22
26
|
/**
|
|
@@ -33,61 +37,7 @@ export class UrlService {
|
|
|
33
37
|
* @type {UrlConfig}
|
|
34
38
|
*/
|
|
35
39
|
this.config = new UrlConfig(this.router);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Gets the current url, or updates the url
|
|
39
|
-
*
|
|
40
|
-
* ### Getting the current URL
|
|
41
|
-
*
|
|
42
|
-
* When no arguments are passed, returns the current URL.
|
|
43
|
-
* The URL is normalized using the internal [[path]]/[[search]]/[[hash]] values.
|
|
44
|
-
*
|
|
45
|
-
* For example, the URL may be stored in the hash ([[HashLocationServices]]) or
|
|
46
|
-
* have a base HREF prepended ([[PushStateLocationServices]]).
|
|
47
|
-
*
|
|
48
|
-
* The raw URL in the browser might be:
|
|
49
|
-
*
|
|
50
|
-
* ```
|
|
51
|
-
* http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor
|
|
52
|
-
* ```
|
|
53
|
-
*
|
|
54
|
-
* or
|
|
55
|
-
*
|
|
56
|
-
* ```
|
|
57
|
-
* http://mysite.com/basepath/internal/path/123?param1=foo#anchor
|
|
58
|
-
* ```
|
|
59
|
-
*
|
|
60
|
-
* then this method returns:
|
|
61
|
-
*
|
|
62
|
-
* ```
|
|
63
|
-
* /internal/path/123?param1=foo#anchor
|
|
64
|
-
* ```
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* #### Example:
|
|
68
|
-
* ```js
|
|
69
|
-
* locationServices.url(); // "/some/path?query=value#anchor"
|
|
70
|
-
* ```
|
|
71
|
-
*
|
|
72
|
-
* ### Updating the URL
|
|
73
|
-
*
|
|
74
|
-
* When `newurl` arguments is provided, changes the URL to reflect `newurl`
|
|
75
|
-
*
|
|
76
|
-
* #### Example:
|
|
77
|
-
* ```js
|
|
78
|
-
* locationServices.url("/some/path?query=value#anchor", true);
|
|
79
|
-
* ```
|
|
80
|
-
*
|
|
81
|
-
* @param {string} newurl The new value for the URL.
|
|
82
|
-
* This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.
|
|
83
|
-
* It should not include the protocol, site, port, or base path of an absolute HREF.
|
|
84
|
-
* @param {boolean} replace When true, replaces the current history entry (instead of appending it) with this new url
|
|
85
|
-
* @param {any} state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
|
|
86
|
-
*
|
|
87
|
-
* @return the url (after potentially being processed)
|
|
88
|
-
*/
|
|
89
|
-
this.url = (newurl, replace, state) =>
|
|
90
|
-
this.router.locationService.url(newurl, replace, state);
|
|
40
|
+
|
|
91
41
|
/**
|
|
92
42
|
* Gets the path part of the current url
|
|
93
43
|
*
|
|
@@ -95,7 +45,7 @@ export class UrlService {
|
|
|
95
45
|
*
|
|
96
46
|
* @return the path portion of the url
|
|
97
47
|
*/
|
|
98
|
-
this.path = () => this.
|
|
48
|
+
this.path = () => this.$location.path();
|
|
99
49
|
/**
|
|
100
50
|
* Gets the search part of the current url as an object
|
|
101
51
|
*
|
|
@@ -103,7 +53,7 @@ export class UrlService {
|
|
|
103
53
|
*
|
|
104
54
|
* @return the search (query) portion of the url, as an object
|
|
105
55
|
*/
|
|
106
|
-
this.search = () => this.
|
|
56
|
+
this.search = () => this.$location.search();
|
|
107
57
|
/**
|
|
108
58
|
* Gets the hash part of the current url
|
|
109
59
|
*
|
|
@@ -111,30 +61,103 @@ export class UrlService {
|
|
|
111
61
|
*
|
|
112
62
|
* @return the hash (anchor) portion of the url
|
|
113
63
|
*/
|
|
114
|
-
this.hash = () => this.
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
* ```js
|
|
124
|
-
* let deregisterFn = locationServices.onChange((evt) => console.log("url change", evt));
|
|
125
|
-
* ```
|
|
126
|
-
*
|
|
127
|
-
* @param callback a function that will be called when the url is changing
|
|
128
|
-
* @return a function that de-registers the callback
|
|
129
|
-
*/
|
|
130
|
-
this.onChange = (callback) =>
|
|
131
|
-
this.router.locationService.onChange(callback);
|
|
64
|
+
this.hash = () => this.$location.hash();
|
|
65
|
+
|
|
66
|
+
this._urlListeners = [];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
html5Mode() {
|
|
70
|
+
let html5Mode = this.$locationProvider.html5Mode();
|
|
71
|
+
html5Mode = isObject(html5Mode) ? html5Mode.enabled : html5Mode;
|
|
72
|
+
return html5Mode && typeof history !== "undefined";
|
|
132
73
|
}
|
|
133
74
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
75
|
+
baseHref() {
|
|
76
|
+
return (
|
|
77
|
+
this._baseHref ||
|
|
78
|
+
(this._baseHref = this.$browser.baseHref() || window.location.pathname)
|
|
79
|
+
);
|
|
137
80
|
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Gets the current url, or updates the url
|
|
84
|
+
*
|
|
85
|
+
* ### Getting the current URL
|
|
86
|
+
*
|
|
87
|
+
* When no arguments are passed, returns the current URL.
|
|
88
|
+
* The URL is normalized using the internal [[path]]/[[search]]/[[hash]] values.
|
|
89
|
+
*
|
|
90
|
+
* For example, the URL may be stored in the hash ([[HashLocationServices]]) or
|
|
91
|
+
* have a base HREF prepended ([[PushStateLocationServices]]).
|
|
92
|
+
*
|
|
93
|
+
* The raw URL in the browser might be:
|
|
94
|
+
*
|
|
95
|
+
* ```
|
|
96
|
+
* http://mysite.com/somepath/index.html#/internal/path/123?param1=foo#anchor
|
|
97
|
+
* ```
|
|
98
|
+
*
|
|
99
|
+
* or
|
|
100
|
+
*
|
|
101
|
+
* ```
|
|
102
|
+
* http://mysite.com/basepath/internal/path/123?param1=foo#anchor
|
|
103
|
+
* ```
|
|
104
|
+
*
|
|
105
|
+
* then this method returns:
|
|
106
|
+
*
|
|
107
|
+
* ```
|
|
108
|
+
* /internal/path/123?param1=foo#anchor
|
|
109
|
+
* ```
|
|
110
|
+
*
|
|
111
|
+
*
|
|
112
|
+
* #### Example:
|
|
113
|
+
* ```js
|
|
114
|
+
* locationServices.url(); // "/some/path?query=value#anchor"
|
|
115
|
+
* ```
|
|
116
|
+
*
|
|
117
|
+
* ### Updating the URL
|
|
118
|
+
*
|
|
119
|
+
* When `newurl` arguments is provided, changes the URL to reflect `newurl`
|
|
120
|
+
*
|
|
121
|
+
* #### Example:
|
|
122
|
+
* ```js
|
|
123
|
+
* locationServices.url("/some/path?query=value#anchor", true);
|
|
124
|
+
* ```
|
|
125
|
+
*
|
|
126
|
+
* @param {string} newUrl The new value for the URL.
|
|
127
|
+
* This url should reflect only the new internal [[path]], [[search]], and [[hash]] values.
|
|
128
|
+
* It should not include the protocol, site, port, or base path of an absolute HREF.
|
|
129
|
+
* @param {boolean} replace When true, replaces the current history entry (instead of appending it) with this new url
|
|
130
|
+
* @param {any} state The history's state object, i.e., pushState (if the LocationServices implementation supports it)
|
|
131
|
+
*
|
|
132
|
+
* @return the url (after potentially being processed)
|
|
133
|
+
*/
|
|
134
|
+
url(newUrl, replace = false, state) {
|
|
135
|
+
if (isDefined(newUrl)) this.$location.url(newUrl);
|
|
136
|
+
if (replace) this.$location.replace();
|
|
137
|
+
if (state) this.$location.state(state);
|
|
138
|
+
return this.$location.url();
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
*
|
|
144
|
+
* Registers a low level url change handler
|
|
145
|
+
*
|
|
146
|
+
* Note: Because this is a low level handler, it's not recommended for general use.
|
|
147
|
+
*
|
|
148
|
+
* #### Example:
|
|
149
|
+
* ```js
|
|
150
|
+
* let deregisterFn = locationServices.onChange((evt) => console.log("url change", evt));
|
|
151
|
+
* ```
|
|
152
|
+
*
|
|
153
|
+
* @param callback a function that will be called when the url is changing
|
|
154
|
+
* @return a function that de-registers the callback
|
|
155
|
+
*/
|
|
156
|
+
onChange(callback) {
|
|
157
|
+
this._urlListeners.push(callback);
|
|
158
|
+
return () => removeFrom(this._urlListeners)(callback);
|
|
159
|
+
}
|
|
160
|
+
|
|
138
161
|
/**
|
|
139
162
|
* Gets the current URL parts
|
|
140
163
|
*
|
|
@@ -275,4 +298,14 @@ export class UrlService {
|
|
|
275
298
|
}
|
|
276
299
|
return best;
|
|
277
300
|
}
|
|
301
|
+
|
|
302
|
+
_runtimeServices($rootScope, $location, $browser) {
|
|
303
|
+
/** @type {angular.ILocationService} */
|
|
304
|
+
this.$location = $location;
|
|
305
|
+
this.$browser = $browser;
|
|
306
|
+
// Bind $locationChangeSuccess to the listeners registered in LocationService.onChange
|
|
307
|
+
$rootScope.$on("$locationChangeSuccess", (evt) =>
|
|
308
|
+
this._urlListeners.forEach((fn) => fn(evt)),
|
|
309
|
+
);
|
|
310
|
+
}
|
|
278
311
|
}
|