aboutsummaryrefslogtreecommitdiffstats
path: root/src/service/route.js
diff options
context:
space:
mode:
authorVojta Jina2011-07-02 01:38:03 +0200
committerVojta Jina2011-07-13 11:49:16 +0200
commit7e2e7b07b6a79a64891f3f2408fb6c325a499e51 (patch)
treebf39157ba4ec22368abd8f0a924c37c21693d0dd /src/service/route.js
parentce80576e0b8ac9ed5a5b1f1a4dbc2446434a0002 (diff)
downloadangular.js-7e2e7b07b6a79a64891f3f2408fb6c325a499e51.tar.bz2
doc($route): fix $route example and couple of typos
Rewrite $route example a bit, as it required $location and $route services to be eager published in the root scope. Fix small typos in formatter and ng:options docs.
Diffstat (limited to 'src/service/route.js')
-rw-r--r--src/service/route.js36
1 files changed, 20 insertions, 16 deletions
diff --git a/src/service/route.js b/src/service/route.js
index 19fc81bf..b04c5ebb 100644
--- a/src/service/route.js
+++ b/src/service/route.js
@@ -22,13 +22,16 @@
<doc:example>
<doc:source>
<script>
- angular.service('myApp', function($route) {
- $route.when('/Book/:bookId', {template:'rsrc/book.html', controller:BookCntl});
- $route.when('/Book/:bookId/ch/:chapterId', {template:'rsrc/chapter.html', controller:ChapterCntl});
+ function MainCntl($route, $location) {
+ this.$route = $route;
+ this.$location = $location;
+
+ $route.when('/Book/:bookId', {template: 'examples/book.html', controller: BookCntl});
+ $route.when('/Book/:bookId/ch/:chapterId', {template: 'examples/chapter.html', controller: ChapterCntl});
$route.onChange(function() {
$route.current.scope.params = $route.current.params;
});
- }, {$inject: ['$route']});
+ }
function BookCntl() {
this.name = "BookCntl";
@@ -39,18 +42,19 @@
}
</script>
- Chose:
- <a href="#/Book/Moby">Moby</a> |
- <a href="#/Book/Moby/ch/1">Moby: Ch1</a> |
- <a href="#/Book/Gatsby">Gatsby</a> |
- <a href="#/Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a><br/>
- <input type="text" name="$location.hashPath" size="80" />
- <pre>$location={{$location}}</pre>
- <pre>$route.current.template={{$route.current.template}}</pre>
- <pre>$route.current.params={{$route.current.params}}</pre>
- <pre>$route.current.scope.name={{$route.current.scope.name}}</pre>
- <hr/>
- <ng:include src="$route.current.template" scope="$route.current.scope"/>
+ <div ng:controller="MainCntl">
+ Choose:
+ <a href="#/Book/Moby">Moby</a> |
+ <a href="#/Book/Moby/ch/1">Moby: Ch1</a> |
+ <a href="#/Book/Gatsby">Gatsby</a> |
+ <a href="#/Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a><br/>
+ $location.hashPath: <input type="text" name="$location.hashPath" size="80" />
+ <pre>$route.current.template = {{$route.current.template}}</pre>
+ <pre>$route.current.params = {{$route.current.params}}</pre>
+ <pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
+ <hr />
+ <ng:view></ng:view>
+ </div>
</doc:source>
<doc:scenario>
</doc:scenario>