Last active
August 29, 2015 14:24
-
-
Save jcarley/9959228e8915559732a2 to your computer and use it in GitHub Desktop.
Angular custom service class using revealing module pattern in coffeescript
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
# See http://goo.gl/hPkgvm for a view of the generated source | |
do -> | |
angular | |
.module('blocks.logger') | |
.factory('logger', logger) | |
logger.$inject = ['$log'] | |
logger = ($log) -> | |
error = (message, data, title) -> | |
toastr.error(message, title) | |
$log.error("Error: #{message}", data) | |
info = (message, data, title) -> | |
toastr.info(message, title) | |
$log.info("Info: #{message}", data) | |
success = (message, data, title) -> | |
toastr.success(message, title) | |
$log.success("Success: #{message}", data) | |
warning = (message, data, title) -> | |
toastr.warning(message, title) | |
$log.warning("Warning: #{message}", data) | |
showToasts: true | |
error: error | |
info: info | |
success: success | |
warning: warning | |
log: $log.log |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment