diff options
| -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"> |
