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

Commit 68e84ac

Browse files
UnicodeSnowmanbtford
authored andcommitted
docs(ngView): remove global controller definitions
instead use angular modules also fix formatting
1 parent e118a8b commit 68e84ac

File tree

1 file changed

+32
-31
lines changed

1 file changed

+32
-31
lines changed

src/ngRoute/directive/ngView.js

Lines changed: 32 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -119,38 +119,39 @@ ngRouteModule.directive('ngView', ngViewFillContentFactory);
119119
</file>
120120
121121
<file name="script.js">
122-
angular.module('ngViewExample', ['ngRoute', 'ngAnimate'],
123-
function($routeProvider, $locationProvider) {
124-
$routeProvider.when('/Book/:bookId', {
125-
templateUrl: 'book.html',
126-
controller: BookCtrl,
127-
controllerAs: 'book'
128-
});
129-
$routeProvider.when('/Book/:bookId/ch/:chapterId', {
130-
templateUrl: 'chapter.html',
131-
controller: ChapterCtrl,
132-
controllerAs: 'chapter'
133-
});
122+
angular.module('ngViewExample', ['ngRoute', 'ngAnimate'])
123+
.config(['$routeProvider', '$locationProvider',
124+
function($routeProvider, $locationProvider) {
125+
$routeProvider
126+
.when('/Book/:bookId', {
127+
templateUrl: 'book.html',
128+
controller: 'BookCtrl',
129+
controllerAs: 'book'
130+
})
131+
.when('/Book/:bookId/ch/:chapterId', {
132+
templateUrl: 'chapter.html',
133+
controller: 'ChapterCtrl',
134+
controllerAs: 'chapter'
135+
});
136+
137+
// configure html5 to get links working on jsfiddle
138+
$locationProvider.html5Mode(true);
139+
}])
140+
.controller('MainCtrl', ['$route', '$routeParams', '$location',
141+
function($route, $routeParams, $location) {
142+
this.$route = $route;
143+
this.$location = $location;
144+
this.$routeParams = $routeParams;
145+
}])
146+
.controller('BookCtrl', ['$routeParams', function($routeParams) {
147+
this.name = "BookCtrl";
148+
this.params = $routeParams;
149+
}])
150+
.controller('ChapterCtrl', ['$routeParams', function($routeParams) {
151+
this.name = "ChapterCtrl";
152+
this.params = $routeParams;
153+
}]);
134154
135-
// configure html5 to get links working on jsfiddle
136-
$locationProvider.html5Mode(true);
137-
});
138-
139-
function MainCtrl($route, $routeParams, $location) {
140-
this.$route = $route;
141-
this.$location = $location;
142-
this.$routeParams = $routeParams;
143-
}
144-
145-
function BookCtrl($routeParams) {
146-
this.name = "BookCtrl";
147-
this.params = $routeParams;
148-
}
149-
150-
function ChapterCtrl($routeParams) {
151-
this.name = "ChapterCtrl";
152-
this.params = $routeParams;
153-
}
154155
</file>
155156
156157
<file name="protractor.js" type="protractor">

0 commit comments

Comments
 (0)