Skip to content

Commit c49ec73

Browse files
Improved the HTML5 mode docs
1 parent b304fe7 commit c49ec73

File tree

1 file changed

+49
-46
lines changed

1 file changed

+49
-46
lines changed

index.html

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
<ul>
1919
<li><a href="#introduction">Introduction</a></li>
2020
<li><a href="#getting-started">Getting Started</a></li>
21-
<li><a href="#html5">HTML5 mode</a></li>
2221
<li><a href="#howto">How To</a></li>
22+
<li><a href="#html5">HTML5 mode</a></li>
2323
<li><a href="#configurations">Configurations</a></li>
2424
<li><a href="#customizations">Customizations</a></li>
2525
<li><a href="#events">Events</a></li>
@@ -95,50 +95,6 @@ <h2>What does it do?</h2>
9595
</section>
9696

9797

98-
<section>
99-
<div class="content">
100-
101-
<h1 id="html5">HTML5 mode</h1>
102-
103-
104-
<h2>HTML5 mode ON</h2>
105-
106-
<p>The oauth directive works just straight when the <a href="https://docs.angularjs.org/guide/$location#general-overview-of-the-api">HTML5 mode</a> is active.</p>
107-
108-
<pre><code><xmp><script>
109-
angular.module('app').config(function($locationProvider) {
110-
$locationProvider.html5Mode(true).hashPrefix('!');
111-
});</script></xmp></code></pre>
112-
113-
114-
<h2>HTML5 mode OFF</h2>
115-
116-
<p>When the HTML5 mode is off add the following snippet of code to your routing provider.</p>
117-
118-
<pre><code><xmp>angular.module('app').config(function ($routeProvider) {
119-
$routeProvider
120-
.when('/access_token=:accessToken', {
121-
template: '',
122-
controller: function ($location, AccessToken) {
123-
var hash = $location.path().substr(1);
124-
AccessToken.setTokenFromString(hash);
125-
$location.path('/');
126-
$location.replace();
127-
}
128-
})
129-
...</xmp></code></pre>
130-
131-
132-
<p>
133-
This code is needed because the fragment that the OAuth 2.0 server returns is recognized
134-
as the routing path <code>/access_token</code>. For this reason you need to add a routing
135-
rule catching the access token, parse it and then redirect to the desired view of your app.
136-
</p>
137-
138-
</div>
139-
</section>
140-
141-
14298
<section>
14399
<div class="content">
144100

@@ -255,7 +211,7 @@ <h2>AngularJS app definition</h2>
255211
<h2>Activate the HTML5 mode</h2>
256212

257213
<p>
258-
Activate the HTML5 mode to easily catch the access token.
214+
Activate the HTML5 mode to catch the access token.
259215
</p>
260216

261217
<pre><code><xmp>// app/scripts/app.js
@@ -371,6 +327,53 @@ <h2>You're done!</h2>
371327

372328

373329

330+
<section>
331+
<div class="content">
332+
333+
<h1 id="html5">HTML5 mode</h1>
334+
335+
336+
<h2>HTML5 mode ON</h2>
337+
338+
<p>The oauth directive works just straight when the <a href="https://docs.angularjs.org/guide/$location#general-overview-of-the-api">HTML5 mode</a> is active.</p>
339+
340+
<pre><code><xmp><script>
341+
angular.module('app').config(function($locationProvider) {
342+
$locationProvider.html5Mode(true).hashPrefix('!');
343+
});</script></xmp></code></pre>
344+
345+
346+
<h2>HTML5 mode OFF</h2>
347+
348+
<p>
349+
When the HTML5 mode is off (default setup on AngularJS) add the following
350+
snippet of code to your routing provider.
351+
</p>
352+
353+
<pre><code><xmp>angular.module('app').config(function ($routeProvider) {
354+
$routeProvider
355+
.when('/access_token=:accessToken', {
356+
template: '',
357+
controller: function ($location, AccessToken) {
358+
var hash = $location.path().substr(1);
359+
AccessToken.setTokenFromString(hash);
360+
$location.path('/');
361+
$location.replace();
362+
}
363+
})
364+
...</xmp></code></pre>
365+
366+
367+
<p>
368+
This code is needed because the fragment that the OAuth 2.0 server returns is recognized
369+
as the routing path <code>/access_token</code>. For this reason you need to add a routing
370+
rule catching the access token, parse it and then redirect to the desired view of your app.
371+
</p>
372+
373+
</div>
374+
</section>
375+
376+
374377
<section>
375378
<div class="content">
376379
<h1 id="configurations">Configurations</h1>

0 commit comments

Comments
 (0)