I’ve just done it this way:
'use strict';
angular.module('MyCustomUrlHandler', [])
.run(['$rootScope', '$window', function($rootScope, $window) {
$window.handleOpenURL = function(url) {
$rootScope.$broadcast('customURL', url);
};
}]);
You can then simply listen to the matching $rootScope.$on event after you’ve required the module:
angular.module('MyApp', ['MyCustomUrlHandler'])
.run(['$rootScope', function($rootScope) {
$rootScope.$on('customURL', function(event, url) {
alert('The URL is: ' + url);
});
}]);