Last active
December 14, 2015 08:59
-
-
Save Sharondio/5061834 to your computer and use it in GitHub Desktop.
AngularJS $rootScope.$apply() attempt (not working, don't copy!)
This file contains 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
'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