From 68e84acec9ebd29daafb35ae7e9435e2ba285530 Mon Sep 17 00:00:00 2001 From: unicodesnowman Date: Sat, 8 Mar 2014 13:04:06 -0500 Subject: docs(ngView): remove global controller definitions instead use angular modules also fix formatting --- src/ngRoute/directive/ngView.js | 63 +++++++++++++++++++++-------------------- 1 file changed, 32 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/ngRoute/directive/ngView.js b/src/ngRoute/directive/ngView.js index a25563ae..85049d4a 100644 --- a/src/ngRoute/directive/ngView.js +++ b/src/ngRoute/directive/ngView.js @@ -119,38 +119,39 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory); - angular.module('ngViewExample', ['ngRoute', 'ngAnimate'], - function($routeProvider, $locationProvider) { - $routeProvider.when('/Book/:bookId', { - templateUrl: 'book.html', - controller: BookCtrl, - controllerAs: 'book' - }); - $routeProvider.when('/Book/:bookId/ch/:chapterId', { - templateUrl: 'chapter.html', - controller: ChapterCtrl, - controllerAs: 'chapter' - }); + angular.module('ngViewExample', ['ngRoute', 'ngAnimate']) + .config(['$routeProvider', '$locationProvider', + function($routeProvider, $locationProvider) { + $routeProvider + .when('/Book/:bookId', { + templateUrl: 'book.html', + controller: 'BookCtrl', + controllerAs: 'book' + }) + .when('/Book/:bookId/ch/:chapterId', { + templateUrl: 'chapter.html', + controller: 'ChapterCtrl', + controllerAs: 'chapter' + }); + + // configure html5 to get links working on jsfiddle + $locationProvider.html5Mode(true); + }]) + .controller('MainCtrl', ['$route', '$routeParams', '$location', + function($route, $routeParams, $location) { + this.$route = $route; + this.$location = $location; + this.$routeParams = $routeParams; + }]) + .controller('BookCtrl', ['$routeParams', function($routeParams) { + this.name = "BookCtrl"; + this.params = $routeParams; + }]) + .controller('ChapterCtrl', ['$routeParams', function($routeParams) { + this.name = "ChapterCtrl"; + this.params = $routeParams; + }]); - // configure html5 to get links working on jsfiddle - $locationProvider.html5Mode(true); - }); - - function MainCtrl($route, $routeParams, $location) { - this.$route = $route; - this.$location = $location; - this.$routeParams = $routeParams; - } - - function BookCtrl($routeParams) { - this.name = "BookCtrl"; - this.params = $routeParams; - } - - function ChapterCtrl($routeParams) { - this.name = "ChapterCtrl"; - this.params = $routeParams; - } -- cgit v1.2.3