You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aio/content/guide/upgrade.md
+10-4Lines changed: 10 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -840,9 +840,9 @@ After this, the service is injectable anywhere in AngularJS code:
840
840
841
841
## Using the Unified Angular Location Service
842
842
843
-
AngularJS and Angular both have separate routers for configuration, handling navigation, encoding and decoding URLs, redirects, and interacting with browser APIs. When migrating from AngularJS to Angular, you have the option of running both routers to handle navigating in different parts of your application. As your migrating from AngularJS, you want to take advantage of new APIs, and move as much of this functionality to Angular.
843
+
In AngularJS, the [$location service](https://docs.angularjs.org/api/ng/service/$location) handles all routing configuration and navigation, encoding and decoding of URLS, redirects, and interactions with browser APIs. Angular uses its own underlying `Location` service for all of these tasks.
844
844
845
-
To aid in your migration from AngularJS to Angular, a unified location service is provided to shift the routing responsibility previously handled by the `$location` provider in AngularJS to Angular.
845
+
When you migrate from AngularJS to Angular you will want to move as much responsibility as possible to Angular, so that you can take advantage of new APIs. To help with the transition, Angular provides the `LocationUpgradeModule`. This module enables a _unified_ location service that shifts responsibilities from the AngularJS `$location` service to the Angular`Location` service.
846
846
847
847
To use the `LocationUpgradeModule`, import the symbol from `@angular/common/upgrade` and add it to your `AppModule` imports using the static `LocationUpgradeModule.config()` method.
848
848
@@ -859,7 +859,7 @@ import { LocationUpgradeModule } from '@angular/common/upgrade';
859
859
exportclassAppModule {}
860
860
```
861
861
862
-
The `LocationUpgradeModule.config()` method accepts a configuration object that allows you configure the `LocationStrategy` with the `useHash` property, and the URL prefix with `hashPrefix` property.
862
+
The `LocationUpgradeModule.config()` method accepts a configuration object that allows you to configure options including the `LocationStrategy` with the `useHash` property, and the URL prefix with the`hashPrefix` property.
863
863
864
864
The `useHash` property defaults to `false`, and the `hashPrefix` defaults to an empty `string`. Pass the configuration object to override the defaults.
This registers the drop-in replacement for the `$location` provider in AngularJS. Once registered, all navigation, routing broadcast messages, and any necessary digest cycles in AngularJS triggered during navigation are handled by Angular. This gives you a single way to navigate within both sides of your hybrid application consistently.
873
+
<divclass="alert is-important">
874
+
875
+
**Note:** See the `LocationUpgradeConfig` for more configuration options available to the `LocationUpgradeModule.config()` method.
876
+
877
+
</div>
878
+
879
+
This registers a drop-in replacement for the `$location` provider in AngularJS. Once registered, all navigation, routing broadcast messages, and any necessary digest cycles in AngularJS triggered during navigation are handled by Angular. This gives you a single way to navigate within both sides of your hybrid application consistently.
874
880
875
881
For usage of the `$location` service as a provider in AngularJS, you need to downgrade the `$locationShim` using a factory provider.
0 commit comments