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

Commit 39635fd

Browse files
bradwheelvojtajina
authored andcommitted
docs(ngRoute): remove global controller syntax in the example
1 parent cad307f commit 39635fd

File tree

1 file changed

+26
-23
lines changed

1 file changed

+26
-23
lines changed

src/ngRoute/route.js

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ function $RouteProvider(){
271271
* <example name="$route-service" module="ngRouteExample"
272272
* deps="angular-route.js" fixBase="true">
273273
* <file name="index.html">
274-
* <div ng-controller="MainCntl">
274+
* <div ng-controller="MainController">
275275
* Choose:
276276
* <a href="Book/Moby">Moby</a> |
277277
* <a href="Book/Moby/ch/1">Moby: Ch1</a> |
@@ -280,6 +280,7 @@ function $RouteProvider(){
280280
* <a href="Book/Scarlet">Scarlet Letter</a><br/>
281281
*
282282
* <div ng-view></div>
283+
*
283284
* <hr />
284285
*
285286
* <pre>$location.path() = {{$location.path()}}</pre>
@@ -304,10 +305,27 @@ function $RouteProvider(){
304305
* <file name="script.js">
305306
* angular.module('ngRouteExample', ['ngRoute'])
306307
*
308+
* .controller('MainController', function($scope, $route, $routeParams, $location) {
309+
* $scope.$route = $route;
310+
* $scope.$location = $location;
311+
* $scope.$routeParams = $routeParams;
312+
* })
313+
*
314+
* .controller('BookController', function($scope, $routeParams) {
315+
* $scope.name = "BookController";
316+
* $scope.params = $routeParams;
317+
* })
318+
*
319+
* .controller('ChapterController', function($scope, $routeParams) {
320+
* $scope.name = "ChapterController";
321+
* $scope.params = $routeParams;
322+
* })
323+
*
307324
* .config(function($routeProvider, $locationProvider) {
308-
* $routeProvider.when('/Book/:bookId', {
325+
* $routeProvider
326+
* .when('/Book/:bookId', {
309327
* templateUrl: 'book.html',
310-
* controller: BookCntl,
328+
* controller: 'BookController',
311329
* resolve: {
312330
* // I will cause a 1 second delay
313331
* delay: function($q, $timeout) {
@@ -316,45 +334,30 @@ function $RouteProvider(){
316334
* return delay.promise;
317335
* }
318336
* }
319-
* });
320-
* $routeProvider.when('/Book/:bookId/ch/:chapterId', {
337+
* })
338+
* .when('/Book/:bookId/ch/:chapterId', {
321339
* templateUrl: 'chapter.html',
322-
* controller: ChapterCntl
340+
* controller: 'ChapterController'
323341
* });
324342
*
325343
* // configure html5 to get links working on jsfiddle
326344
* $locationProvider.html5Mode(true);
327345
* });
328346
*
329-
* function MainCntl($scope, $route, $routeParams, $location) {
330-
* $scope.$route = $route;
331-
* $scope.$location = $location;
332-
* $scope.$routeParams = $routeParams;
333-
* }
334-
*
335-
* function BookCntl($scope, $routeParams) {
336-
* $scope.name = "BookCntl";
337-
* $scope.params = $routeParams;
338-
* }
339-
*
340-
* function ChapterCntl($scope, $routeParams) {
341-
* $scope.name = "ChapterCntl";
342-
* $scope.params = $routeParams;
343-
* }
344347
* </file>
345348
*
346349
* <file name="protractor.js" type="protractor">
347350
* it('should load and compile correct template', function() {
348351
* element(by.linkText('Moby: Ch1')).click();
349352
* var content = element(by.css('[ng-view]')).getText();
350-
* expect(content).toMatch(/controller\: ChapterCntl/);
353+
* expect(content).toMatch(/controller\: ChapterController/);
351354
* expect(content).toMatch(/Book Id\: Moby/);
352355
* expect(content).toMatch(/Chapter Id\: 1/);
353356
*
354357
* element(by.partialLinkText('Scarlet')).click();
355358
*
356359
* content = element(by.css('[ng-view]')).getText();
357-
* expect(content).toMatch(/controller\: BookCntl/);
360+
* expect(content).toMatch(/controller\: BookController/);
358361
* expect(content).toMatch(/Book Id\: Scarlet/);
359362
* });
360363
* </file>

0 commit comments

Comments
 (0)