@@ -262,102 +262,103 @@ function $RouteProvider(){
262262 * {@link ngRoute.$routeParams `$routeParams`} service.
263263 *
264264 * @example
265- This example shows how changing the URL hash causes the `$route` to match a route against the
266- URL, and the `ngView` pulls in the partial.
267-
268- Note that this example is using {@link ng.directive:script inlined templates}
269- to get it working on jsfiddle as well.
270-
271- <example name="$route-service" module="ngRouteExample" deps="angular-route.js" fixBase="true">
272- <file name="index.html">
273- <div ng-controller="MainCntl">
274- Choose:
275- <a href="Book/Moby">Moby</a> |
276- <a href="Book/Moby/ch/1">Moby: Ch1</a> |
277- <a href="Book/Gatsby">Gatsby</a> |
278- <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
279- <a href="Book/Scarlet">Scarlet Letter</a><br/>
280-
281- <div ng-view></div>
282- <hr />
283-
284- <pre>$location.path() = {{$location.path()}}</pre>
285- <pre>$route.current.templateUrl = {{$route.current.templateUrl}}</pre>
286- <pre>$route.current.params = {{$route.current.params}}</pre>
287- <pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
288- <pre>$routeParams = {{$routeParams}}</pre>
289- </div>
290- </file>
291-
292- <file name="book.html">
293- controller: {{name}}<br />
294- Book Id: {{params.bookId}}<br />
295- </file>
296-
297- <file name="chapter.html">
298- controller: {{name}}<br />
299- Book Id: {{params.bookId}}<br />
300- Chapter Id: {{params.chapterId}}
301- </file>
302-
303- <file name="script.js">
304- angular.module('ngRouteExample', ['ngRoute'])
305-
306- .config(function($routeProvider, $locationProvider) {
307- $routeProvider.when('/Book/:bookId', {
308- templateUrl: 'book.html',
309- controller: BookCntl,
310- resolve: {
311- // I will cause a 1 second delay
312- delay: function($q, $timeout) {
313- var delay = $q.defer();
314- $timeout(delay.resolve, 1000);
315- return delay.promise;
316- }
317- }
318- });
319- $routeProvider.when('/Book/:bookId/ch/:chapterId', {
320- templateUrl: 'chapter.html',
321- controller: ChapterCntl
322- });
323-
324- // configure html5 to get links working on jsfiddle
325- $locationProvider.html5Mode(true);
326- });
327-
328- function MainCntl($scope, $route, $routeParams, $location) {
329- $scope.$route = $route;
330- $scope.$location = $location;
331- $scope.$routeParams = $routeParams;
332- }
333-
334- function BookCntl($scope, $routeParams) {
335- $scope.name = "BookCntl";
336- $scope.params = $routeParams;
337- }
338-
339- function ChapterCntl($scope, $routeParams) {
340- $scope.name = "ChapterCntl";
341- $scope.params = $routeParams;
342- }
343- </file>
344-
345- <file name="protractor.js" type="protractor">
346- it('should load and compile correct template', function() {
347- element(by.linkText('Moby: Ch1')).click();
348- var content = element(by.css('[ng-view]')).getText();
349- expect(content).toMatch(/controller\: ChapterCntl/);
350- expect(content).toMatch(/Book Id\: Moby/);
351- expect(content).toMatch(/Chapter Id\: 1/);
352-
353- element(by.partialLinkText('Scarlet')).click();
354-
355- content = element(by.css('[ng-view]')).getText();
356- expect(content).toMatch(/controller\: BookCntl/);
357- expect(content).toMatch(/Book Id\: Scarlet/);
358- });
359- </file>
360- </example>
265+ * This example shows how changing the URL hash causes the `$route` to match a route against the
266+ * URL, and the `ngView` pulls in the partial.
267+ *
268+ * Note that this example is using {@link ng.directive:script inlined templates}
269+ * to get it working on jsfiddle as well.
270+ *
271+ * <example name="$route-service" module="ngRouteExample"
272+ * deps="angular-route.js" fixBase="true">
273+ * <file name="index.html">
274+ * <div ng-controller="MainCntl">
275+ * Choose:
276+ * <a href="Book/Moby">Moby</a> |
277+ * <a href="Book/Moby/ch/1">Moby: Ch1</a> |
278+ * <a href="Book/Gatsby">Gatsby</a> |
279+ * <a href="Book/Gatsby/ch/4?key=value">Gatsby: Ch4</a> |
280+ * <a href="Book/Scarlet">Scarlet Letter</a><br/>
281+ *
282+ * <div ng-view></div>
283+ * <hr />
284+ *
285+ * <pre>$location.path() = {{$location.path()}}</pre>
286+ * <pre>$route.current.templateUrl = {{$route.current.templateUrl}}</pre>
287+ * <pre>$route.current.params = {{$route.current.params}}</pre>
288+ * <pre>$route.current.scope.name = {{$route.current.scope.name}}</pre>
289+ * <pre>$routeParams = {{$routeParams}}</pre>
290+ * </div>
291+ * </file>
292+ *
293+ * <file name="book.html">
294+ * controller: {{name}}<br />
295+ * Book Id: {{params.bookId}}<br />
296+ * </file>
297+ *
298+ * <file name="chapter.html">
299+ * controller: {{name}}<br />
300+ * Book Id: {{params.bookId}}<br />
301+ * Chapter Id: {{params.chapterId}}
302+ * </file>
303+ *
304+ * <file name="script.js">
305+ * angular.module('ngRouteExample', ['ngRoute'])
306+ *
307+ * .config(function($routeProvider, $locationProvider) {
308+ * $routeProvider.when('/Book/:bookId', {
309+ * templateUrl: 'book.html',
310+ * controller: BookCntl,
311+ * resolve: {
312+ * // I will cause a 1 second delay
313+ * delay: function($q, $timeout) {
314+ * var delay = $q.defer();
315+ * $timeout(delay.resolve, 1000);
316+ * return delay.promise;
317+ * }
318+ * }
319+ * });
320+ * $routeProvider.when('/Book/:bookId/ch/:chapterId', {
321+ * templateUrl: 'chapter.html',
322+ * controller: ChapterCntl
323+ * });
324+ *
325+ * // configure html5 to get links working on jsfiddle
326+ * $locationProvider.html5Mode(true);
327+ * });
328+ *
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+ * }
344+ * </file>
345+ *
346+ * <file name="protractor.js" type="protractor">
347+ * it('should load and compile correct template', function() {
348+ * element(by.linkText('Moby: Ch1')).click();
349+ * var content = element(by.css('[ng-view]')).getText();
350+ * expect(content).toMatch(/controller\: ChapterCntl/);
351+ * expect(content).toMatch(/Book Id\: Moby/);
352+ * expect(content).toMatch(/Chapter Id\: 1/);
353+ *
354+ * element(by.partialLinkText('Scarlet')).click();
355+ *
356+ * content = element(by.css('[ng-view]')).getText();
357+ * expect(content).toMatch(/controller\: BookCntl/);
358+ * expect(content).toMatch(/Book Id\: Scarlet/);
359+ * });
360+ * </file>
361+ * </example>
361362 */
362363
363364 /**
0 commit comments