From 55a0bc453c3cf5196c2b1f55e293b0eb19781b44 Mon Sep 17 00:00:00 2001 From: bradwheel Date: Sat, 8 Mar 2014 20:23:31 -0500 Subject: docs(ngRoute): remove global controller syntax in the example --- src/ngRoute/route.js | 49 ++++++++++++++++++++++++++----------------------- 1 file changed, 26 insertions(+), 23 deletions(-) (limited to 'src') diff --git a/src/ngRoute/route.js b/src/ngRoute/route.js index 1319dd02..0f302e37 100644 --- a/src/ngRoute/route.js +++ b/src/ngRoute/route.js @@ -271,7 +271,7 @@ function $RouteProvider(){ * * - *
+ *
* Choose: * Moby | * Moby: Ch1 | @@ -280,6 +280,7 @@ function $RouteProvider(){ * Scarlet Letter
* *
+ * *
* *
$location.path() = {{$location.path()}}
@@ -304,10 +305,27 @@ function $RouteProvider(){ * * angular.module('ngRouteExample', ['ngRoute']) * + * .controller('MainController', function($scope, $route, $routeParams, $location) { + * $scope.$route = $route; + * $scope.$location = $location; + * $scope.$routeParams = $routeParams; + * }) + * + * .controller('BookController', function($scope, $routeParams) { + * $scope.name = "BookController"; + * $scope.params = $routeParams; + * }) + * + * .controller('ChapterController', function($scope, $routeParams) { + * $scope.name = "ChapterController"; + * $scope.params = $routeParams; + * }) + * * .config(function($routeProvider, $locationProvider) { - * $routeProvider.when('/Book/:bookId', { + * $routeProvider + * .when('/Book/:bookId', { * templateUrl: 'book.html', - * controller: BookCntl, + * controller: 'BookController', * resolve: { * // I will cause a 1 second delay * delay: function($q, $timeout) { @@ -316,45 +334,30 @@ function $RouteProvider(){ * return delay.promise; * } * } - * }); - * $routeProvider.when('/Book/:bookId/ch/:chapterId', { + * }) + * .when('/Book/:bookId/ch/:chapterId', { * templateUrl: 'chapter.html', - * controller: ChapterCntl + * controller: 'ChapterController' * }); * * // configure html5 to get links working on jsfiddle * $locationProvider.html5Mode(true); * }); * - * function MainCntl($scope, $route, $routeParams, $location) { - * $scope.$route = $route; - * $scope.$location = $location; - * $scope.$routeParams = $routeParams; - * } - * - * function BookCntl($scope, $routeParams) { - * $scope.name = "BookCntl"; - * $scope.params = $routeParams; - * } - * - * function ChapterCntl($scope, $routeParams) { - * $scope.name = "ChapterCntl"; - * $scope.params = $routeParams; - * } * * * * it('should load and compile correct template', function() { * element(by.linkText('Moby: Ch1')).click(); * var content = element(by.css('[ng-view]')).getText(); - * expect(content).toMatch(/controller\: ChapterCntl/); + * expect(content).toMatch(/controller\: ChapterController/); * expect(content).toMatch(/Book Id\: Moby/); * expect(content).toMatch(/Chapter Id\: 1/); * * element(by.partialLinkText('Scarlet')).click(); * * content = element(by.css('[ng-view]')).getText(); - * expect(content).toMatch(/controller\: BookCntl/); + * expect(content).toMatch(/controller\: BookController/); * expect(content).toMatch(/Book Id\: Scarlet/); * }); * -- cgit v1.2.3