Skip to content

Instantly share code, notes, and snippets.

@Sharondio
Last active December 14, 2015 08:59
Show Gist options
  • Save Sharondio/5061834 to your computer and use it in GitHub Desktop.
Save Sharondio/5061834 to your computer and use it in GitHub Desktop.
AngularJS $rootScope.$apply() attempt (not working, don't copy!)
'use strict';
module.exports = function (module) {
module.factory('PageEventsService', ['$rootScope', function ($rootScope) {
return {
// can't get it to receive :-(
on: function(event, callback) {
console.log("PageEventsService on");
var pageEventOn = window.pageEvents.on(event, function (data) {
console.log(data);
});
$rootScope.$apply(pageEventOn);
},
// strangely enough, the emit function works
emit: function(event, callback) {
console.log("PageEVentService emit");
var pageEventEmit = window.pageEvents.on(event, function(data) {
console.log(data);
});
$rootScope.$apply(pageEventEmit);
}
}
}]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment