@@ -21,6 +21,9 @@ export class UrlService {
2121
2222 /**
2323 * @param {import("../../core/location/location").LocationProvider } $locationProvider
24+ * @param {import("../../router/state/state-service.js").StateProvider } stateService
25+ * @param globals
26+ * @param {import("../../router/url/url-config.js").UrlConfigProvider } urlConfigProvider
2427 */
2528 constructor ( $locationProvider , stateService , globals , urlConfigProvider ) {
2629 this . stateService = stateService ;
@@ -30,9 +33,6 @@ export class UrlService {
3033 this . $location = undefined ;
3134 this . $browser = undefined ;
3235
33- /** @type {boolean } */
34- this . interceptDeferred = false ;
35-
3636 /** Provides services related to the URL */
3737 this . urlRuleFactory = new UrlRuleFactory ( this , this . stateService , globals ) ;
3838
@@ -91,7 +91,7 @@ export class UrlService {
9191 * @param {import('../../core/location/location').Location } $location
9292 * @param {import('../../services/browser').Browser } $browser
9393 * @param {import('../../core/scope/scope').Scope } $rootScope
94- * @returns
94+ * @returns { UrlService }
9595 */
9696 ( $location , $browser , $rootScope ) => {
9797 this . $location = $location ;
@@ -104,10 +104,14 @@ export class UrlService {
104104 } ,
105105 ] ;
106106
107+ /**
108+ * @returns {boolean }
109+ */
107110 html5Mode ( ) {
108- let html5Mode = this . $locationProvider . html5Mode ( ) ;
109- html5Mode = isObject ( html5Mode ) ? html5Mode . enabled : html5Mode ;
110- return html5Mode && typeof history !== "undefined" ;
111+ return (
112+ this . $locationProvider . getHtml5Mode ( ) . enabled &&
113+ typeof history !== "undefined"
114+ ) ;
111115 }
112116
113117 baseHref ( ) {
@@ -214,7 +218,6 @@ export class UrlService {
214218 *
215219 * #### Example:
216220 * ```js
217- * urlService.deferIntercept();
218221 *
219222 * fetch('/states.json').then(resp => resp.json()).then(data => {
220223 * data.forEach(state => $stateRegistry.register(state));
@@ -261,7 +264,6 @@ export class UrlService {
261264 *
262265 * #### Example:
263266 * ```js
264- * urlService.deferIntercept();
265267 *
266268 * fetch('/states.json').then(resp => resp.json()).then(data => {
267269 * data.forEach(state => $stateRegistry.register(state));
@@ -282,34 +284,7 @@ export class UrlService {
282284 this . _stopListeningFn || this . onChange ( ( evt ) => this . sync ( evt ) ) ) ;
283285 }
284286 }
285- /**
286- * Disables monitoring of the URL.
287- *
288- * Call this method before ng-router has bootstrapped.
289- * It will stop ng-router from performing the initial url sync.
290- *
291- * This can be useful to perform some asynchronous initialization before the router starts.
292- * Once the initialization is complete, call [[listen]] to tell ng-router to start watching and synchronizing the URL.
293- *
294- * #### Example:
295- * ```js
296- * // Prevent ng-router from automatically intercepting URL changes when it starts;
297- * urlService.deferIntercept();
298- *
299- * fetch('/states.json').then(resp => resp.json()).then(data => {
300- * data.forEach(state => $stateRegistry.register(state));
301- * urlService.listen();
302- * urlService.sync();
303- * });
304- * ```
305- *
306- * @param defer Indicates whether to defer location change interception.
307- * Passing no parameter is equivalent to `true`.
308- */
309- deferIntercept ( defer ) {
310- if ( defer === undefined ) defer = true ;
311- this . interceptDeferred = defer ;
312- }
287+
313288 /**
314289 * Matches a URL
315290 *
@@ -394,7 +369,7 @@ export class UrlService {
394369 options = options || { absolute : false } ;
395370 const isHtml5 = this . html5Mode ( ) ;
396371 if ( ! isHtml5 && url !== null ) {
397- url = "#" + this . $locationProvider . hashPrefix ( ) + url ;
372+ url = "#" + this . $locationProvider . getHashPrefix ( ) + url ;
398373 }
399374 url = appendBasePath ( url , isHtml5 , options . absolute , this . baseHref ( ) ) ;
400375 if ( ! options . absolute || ! url ) {
0 commit comments