99In this step, you will learn how to create a layout template and how to build an application that
1010has multiple views by adding routing, using an Angular module called {@link ngRoute ngRoute}.
1111
12- * When you now navigate to `/index.html`, you are redirected to `/index.html#/phones` and the phone
12+ * When you now navigate to `/index.html`, you are redirected to `/index.html#! /phones` and the phone
1313 list appears in the browser.
1414* When you click on a phone link, the URL changes to that specific phone and the stub of a phone
1515 detail page is displayed.
@@ -193,18 +193,20 @@ angular.module('phonecatApp', [
193193]);
194194```
195195
196- Now we can configure the `$route` service (using it's provider) for our application. In order to be
197- able to quickly locate the configuration code, we put it into a separate file and used the `.config`
198- suffix.
196+ Now, in addition to the core services and directives, we can also configure the `$route` service
197+ (using it's provider) for our application. In order to be able to quickly locate the configuration
198+ code, we put it into a separate file and used the `.config` suffix.
199199
200200<br />
201201**`app/app.config.js`:**
202202
203203```js
204204 angular.
205205 module('phonecatApp').
206- config(['$routeProvider',
207- function config($routeProvider) {
206+ config(['$locationProvider', '$routeProvider',
207+ function config($locationProvider, $routeProvider) {
208+ $locationProvider.hashPrefix('!');
209+
208210 $routeProvider.
209211 when('/phones', {
210212 template: '<phone-list></phone-list>'
@@ -217,11 +219,25 @@ suffix.
217219 ]);
218220```
219221
220- Using the `.config()` method, we request the `$routeProvider` to be injected into our configuration
221- function and use the {@link ngRoute.$routeProvider#when $routeProvider.when()} and
222+ Using the `.config()` method, we request the necessary providers (for example the `$routeProvider`)
223+ to be injected into our configuration function and then use their methods to specify the behavior of
224+ the corresponding services. Here, we use the
225+ {@link ngRoute.$routeProvider#when $routeProvider.when()} and
222226{@link ngRoute.$routeProvider#otherwise $routeProvider.otherwise()} methods to define our
223227application routes.
224228
229+ <div class="alert alert-success">
230+ <p>
231+ We also used {@ink $locationProvider#hashPrefix $locationProvider.hashPrefix()} to set the
232+ hash-prefix to `!`. This prefix will appear in the links to our client-side routes, right after
233+ the hash (`#`) symbol and before the actual path (e.g. `index.html#!/some/path`).
234+ </p>
235+ <p>
236+ Setting a prefix is not necessary, but it is considered a good practice (for reasons that are
237+ outside the scope of this tutorial). `!` is the most commonly used prefix.
238+ </p>
239+ </div>
240+
225241Our routes are defined as follows:
226242
227243* `when('/phones')`: Determines the view that will be shown, when the URL hash fragment is
@@ -345,7 +361,7 @@ various URLs and verifying that the correct view was rendered.
345361```js
346362 ...
347363
348- it('should redirect `index.html` to `index.html#/phones', function() {
364+ it('should redirect `index.html` to `index.html#! /phones', function() {
349365 browser.get('index.html');
350366 expect(browser.getLocationAbsUrl()).toBe('/phones');
351367 });
@@ -355,7 +371,7 @@ various URLs and verifying that the correct view was rendered.
355371 describe('View: Phone list', function() {
356372
357373 beforeEach(function() {
358- browser.get('index.html#/phones');
374+ browser.get('index.html#! /phones');
359375 });
360376
361377 ...
@@ -367,7 +383,7 @@ various URLs and verifying that the correct view was rendered.
367383 describe('View: Phone details', function() {
368384
369385 beforeEach(function() {
370- browser.get('index.html#/phones/nexus-s');
386+ browser.get('index.html#! /phones/nexus-s');
371387 });
372388
373389 it('should display placeholder page with `phoneId`', function() {
0 commit comments