Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Commit 2c74a42

Browse files
committed
fixup 4
- Use `!` as hash-prefix.
1 parent 21fa45f commit 2c74a42

File tree

3 files changed

+30
-14
lines changed

3 files changed

+30
-14
lines changed

docs/content/tutorial/step_09.ngdoc

+27-11
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
In this step, you will learn how to create a layout template and how to build an application that
1010
has 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
223227
application 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+
225241
Our 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() {

docs/content/tutorial/step_10.ngdoc

+1-1
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ heading on the page is "Nexus S".
179179
describe('View: Phone detail', function() {
180180

181181
beforeEach(function() {
182-
browser.get('index.html#/phones/nexus-s');
182+
browser.get('index.html#!/phones/nexus-s');
183183
});
184184

185185
it('should display the `nexus-s` page', function() {

docs/content/tutorial/step_14.ngdoc

+2-2
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ order to be able to hook into it with our CSS animation code.
157157
<ul class="phones">
158158
<li ng-repeat="phone in $ctrl.phones | filter:$ctrl.query | orderBy:$ctrl.orderProp"
159159
class="thumbnail phone-list-item">
160-
<a href="#/phones/{{phone.id}}" class="thumb">
160+
<a href="#!/phones/{{phone.id}}" class="thumb">
161161
<img ng-src="{{phone.imageUrl}}" alt="{{phone.name}}" />
162162
</a>
163-
<a href="#/phones/{{phone.id}}">{{phone.name}}</a>
163+
<a href="#!/phones/{{phone.id}}">{{phone.name}}</a>
164164
<p>{{phone.snippet}}</p>
165165
</li>
166166
</ul>

0 commit comments

Comments
 (0)