Created
February 24, 2012 20:04
-
-
Save mhevery/1903387 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!doctype html> | |
<html xmlns:ng="http://angularjs.org" ng:app> | |
<script src="http://docs-next.angularjs.org/angular-0.10.6.min.js"></script> | |
<script> | |
function MainCntl($route, $routeParams, $location) { | |
this.$route = $route; | |
this.$location = $location; | |
this.$routeParams = $routeParams; | |
$route.when('/Book/:bookId', {template: 'examples/book.html', controller: BookCntl}); | |
$route.when('/Book/:bookId/:chapterId', {template: 'examples/chapter.html', controller: ChapterCntl}); | |
} | |
function BookCntl($routeParams) { | |
this.name = "BookCntl"; | |
this.params = $routeParams; | |
} | |
function ChapterCntl($routeParams) { | |
this.name = "ChapterCntl"; | |
this.params = $routeParams; | |
} | |
</script> | |
<body> | |
<div ng:controller="MainCntl"> | |
Choose: | |
<a href="#/Book/Moby">Moby</a> | | |
<a href="#/Book/Moby/1">Moby: Ch1</a> | | |
<a href="#/Book/Gatsby">Gatsby</a> | | |
<a href="#/Book/Gatsby/4?key=value">Gatsby: Ch4</a><br/> | |
<pre>$location.path() = {{$location.path()}}</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> | |
<pre>$routeParams = {{$routeParams}}</pre> | |
<hr /> | |
{{ $route.current | json }} | |
</div> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment