Created
March 24, 2015 01:55
-
-
Save leongaban/ddf2a5807e4a097900c3 to your computer and use it in GitHub Desktop.
scopeFactory
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /*global angular*/ | |
| /* ========================================= | |
| -------------------------------------------- | |
| Save a scope: | |
| var vs = $scope; | |
| ScopeFactory.saveScope('alerts', vs); | |
| Retrieve a scope: | |
| var alertScope = ScopeFactory.getScope('alerts'); | |
| -------------------------------------------- | |
| ============================================ */ | |
| "use strict"; | |
| var app = angular.module('myApp.manage.scopeFactory', []) | |
| .factory('ScopeFactory', [function() { | |
| var termsModalScope = { | |
| that: this | |
| }; | |
| var alertScope = { | |
| that: this | |
| }; | |
| var saveScope = function(type, vs) { | |
| switch(type) { | |
| case 'alerts': | |
| alertScope.that = vs; | |
| break; | |
| case 'termsModal': | |
| termsModalScope.that = vs; | |
| break; | |
| } | |
| }; | |
| var getScope = function(type) { | |
| switch(type) { | |
| case 'alerts': | |
| return alertScope.that; | |
| break; | |
| case 'termsModal': | |
| return termsModalScope.that; | |
| break; | |
| } | |
| }; | |
| return { | |
| saveScope : saveScope, | |
| getScope : getScope | |
| }; | |
| }]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment