$route.onChange should return the registered fn

This commit is contained in:
Igor Minar 2011-02-04 13:29:24 -08:00
parent 568574b915
commit bf7c9d9900
2 changed files with 13 additions and 1 deletions

View file

@ -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

View file

@ -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'),