diff options
| author | Daniel Zimmermann | 2014-01-08 19:58:09 +1100 | 
|---|---|---|
| committer | Igor Minar | 2014-01-10 23:42:36 -0800 | 
| commit | 2b344dbd20777fb1283b3a5bcf35a6ae8d09469d (patch) | |
| tree | 97ce6d628efcda632061d0043d9d8a235f47d631 | |
| parent | cde840fdf839e593108a33e0f3d56a052762f28d (diff) | |
| download | angular.js-2b344dbd20777fb1283b3a5bcf35a6ae8d09469d.tar.bz2 | |
fix($route): update current route upon $route instantiation
This fixes cases where the first ngView is loaded in a template asynchronously (such as through ngInclude), as the service will miss the first  event otherwise.
Closes #4957
| -rw-r--r-- | src/ngRoute/route.js | 1 | ||||
| -rw-r--r-- | test/ngRoute/routeSpec.js | 8 | 
2 files changed, 5 insertions, 4 deletions
| diff --git a/src/ngRoute/route.js b/src/ngRoute/route.js index 34f3f9ec..2db74a02 100644 --- a/src/ngRoute/route.js +++ b/src/ngRoute/route.js @@ -443,6 +443,7 @@ function $RouteProvider(){            }          }; +    updateRoute();      $rootScope.$on('$locationChangeSuccess', updateRoute);      return $route; diff --git a/test/ngRoute/routeSpec.js b/test/ngRoute/routeSpec.js index de7ccb8d..52484116 100644 --- a/test/ngRoute/routeSpec.js +++ b/test/ngRoute/routeSpec.js @@ -389,7 +389,7 @@ describe('$route', function() {          var onChangeSpy = jasmine.createSpy('onChange');          $rootScope.$on('$routeChangeStart', onChangeSpy); -        expect($route.current).toBeUndefined(); +        expect($route.current).not.toBeUndefined();          expect(onChangeSpy).not.toHaveBeenCalled();          $location.path('/unknownRoute'); @@ -426,7 +426,7 @@ describe('$route', function() {          // init          $rootScope.$on('$routeChangeStart', onChangeSpy); -        expect($route.current).toBeUndefined(); +        expect($route.current).not.toBeUndefined();          expect(onChangeSpy).not.toHaveBeenCalled(); @@ -434,7 +434,7 @@ describe('$route', function() {          $location.path('/unknownRoute');          $rootScope.$digest(); -        expect(currentRoute).toBeUndefined(); +        expect(currentRoute).not.toBeUndefined();          expect(nextRoute.templateUrl).toBe('404.html');          expect($route.current.templateUrl).toBe('404.html');          expect(onChangeSpy).toHaveBeenCalled(); @@ -770,7 +770,7 @@ describe('$route', function() {          var onChangeSpy = jasmine.createSpy('onChange');          $rootScope.$on('$routeChangeStart', onChangeSpy); -        expect($route.current).toBeUndefined(); +        expect($route.current).not.toBeUndefined();          expect(onChangeSpy).not.toHaveBeenCalled();          $location.path('/'); | 
