mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-17 07:40:22 +00:00
$route.onChange should return the registered fn
This commit is contained in:
parent
568574b915
commit
bf7c9d9900
2 changed files with 13 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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'),
|
||||
|
|
|
|||
Loading…
Reference in a new issue