Skip to content

Instantly share code, notes, and snippets.

View brettpennings's full-sized avatar

brettpennings

View GitHub Profile
@brettpennings
brettpennings / restoreScope.js
Last active June 24, 2016 21:37
Service for Restoring Scope: this one uses $location instead of $route
angular.module('restoreScope', []).factory('restoreScope', ['$rootScope', '$location', function ($rootScope, $location) {
var currentScope = null;
var getOrRegisterScopeVariable = function (scope, name, defaultValue, storedScope) {
if (storedScope[name] == null) {
storedScope[name] = defaultValue;
}
scope[name] = storedScope[name];
}