(function() { "use strict"; angular.module('shared') .factory('teacherLoginAmbassador', ['$rootScope', dataService]); function dataService($rootScope) { var REQUIRE_LOGIN_ACTIVATED = 'requireLoginActivated'; return { registerOnRequireLoginActivated: registerOnRequireLoginActivated, requireLogin: requireLogin }; function registerOnRequireLoginActivated(scope, callback) { var eventListenerDestructor = $rootScope.$on(REQUIRE_LOGIN_ACTIVATED, callback); scope.$on('$destroy', eventListenerDestructor); } function requireLogin(args) { $rootScope.$emit(REQUIRE_LOGIN_ACTIVATED, args); } } })();