Skip to content

Instantly share code, notes, and snippets.

@leongaban
Created March 24, 2015 01:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leongaban/ddf2a5807e4a097900c3 to your computer and use it in GitHub Desktop.
Save leongaban/ddf2a5807e4a097900c3 to your computer and use it in GitHub Desktop.
scopeFactory
/*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