diff options
| author | unicodesnowman | 2014-03-08 13:04:06 -0500 |
|---|---|---|
| committer | Vojta Jina | 2014-03-21 11:42:17 -0700 |
| commit | a86cb7d794523e11079c5ef47a72192bb885fe37 (patch) | |
| tree | cbbacb68c5ae1fbfdc89534780a5d0d4cd65855d /src/ngRoute/directive/ngView.js | |
| parent | c7e60153a51ea424397fe06102c06e7c3849da56 (diff) | |
| download | angular.js-a86cb7d794523e11079c5ef47a72192bb885fe37.tar.bz2 | |
docs(ngView): remove global controller definitions
instead use angular modules
also fix formatting
Diffstat (limited to 'src/ngRoute/directive/ngView.js')
| -rw-r--r-- | src/ngRoute/directive/ngView.js | 63 |
1 files changed, 32 insertions, 31 deletions
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); </file> <file name="script.js"> - 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; - } </file> <file name="protractor.js" type="protractor"> |
