Skip to content

Instantly share code, notes, and snippets.

@mackwic
Forked from joegaudet/gist:5888481
Last active December 19, 2015 03:09
Show Gist options
  • Save mackwic/5888526 to your computer and use it in GitHub Desktop.
Save mackwic/5888526 to your computer and use it in GitHub Desktop.
$scope.$watch(function () {
return SessionService.currentUser;
}, function (user) {
$scope.user = user;
}, true);
angular.service('MyService', function() {
return {
value: 'default',
handlers: [],
getProperty : function(onChangeCallback) {
handlers.push(onChangeCallback);
return value;
},
setProperty : function(newVal) {
value = newVal;
handlers.forEach(function(e) { e(newVal); });
}
};
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment