diff options
| -rw-r--r-- | src/services.js | 6 | ||||
| -rw-r--r-- | test/servicesSpec.js | 8 |
2 files changed, 13 insertions, 1 deletions
diff --git a/src/services.js b/src/services.js index b7e7c02f..eb0a473f 100644 --- a/src/services.js +++ b/src/services.js @@ -709,11 +709,15 @@ angularServiceInject('$route', function(location) { * @methodOf angular.service.$route * * @param {function()} fn Function that will be called when `$route.current` changes. + * @returns {function()} The registered function. * * @description * Register a handler function that will be called when route changes */ - onChange: bind(onChange, onChange.push), + onChange: function(fn) { + onChange.push(fn); + return fn; + }, /** * @workInProgress diff --git a/test/servicesSpec.js b/test/servicesSpec.js index 70645caf..e3437dc2 100644 --- a/test/servicesSpec.js +++ b/test/servicesSpec.js @@ -410,6 +410,14 @@ describe("service", function(){ expect($route.current.template).toEqual('instant update'); }); + it('should return fn registered with onChange()', function() { + var scope = angular.scope(), + $route = scope.$service('$route'), + fn = function() {}; + + expect($route.onChange(fn)).toBe(fn); + }); + it('should allow routes to be defined with just templates without controllers', function() { var scope = angular.scope(), $location = scope.$service('$location'), |
