-
-
Save iamjohnlong/458ef1aefb06f130c9ad to your computer and use it in GitHub Desktop.
This file contains hidden or 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
module.directive "someDirectiveDispatcher", (Messenger)-> | |
return{ | |
restrict: "E" | |
template: "<h1>Test</h1>" | |
controller: ($scope)-> | |
$scope.elementClickEvent = ()-> | |
Messenger.call Messenger.REFRESH_SOMETHING | |
} |
This file contains hidden or 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
module.factory "Messenger", ($rootScope)-> | |
messenger = {} | |
messenger.message = "" | |
messenger.call = (msg_type, message)-> | |
@message = message | |
@broadcast(msg_type) | |
messenger.broadcast = (msg_type)-> | |
$rootScope.$broadcast msg_type | |
messenger.REFRESH_SOMETHING = "refresh_something" | |
return messenger |
This file contains hidden or 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
module.directive "someDirective", (Messenger)-> | |
updateCode = ()-> | |
console.log "update this thing!" | |
return{ | |
restrict: "E" | |
template: "<h1>Test</h1>" | |
link: ($scope, element, attrs)-> | |
$scope.$on Messenger.REFRESH_SOMETHING, ()-> | |
updateCode() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment