Last active
August 29, 2015 14:05
-
-
Save idleworx/9d75f46e01e646332bd0 to your computer and use it in GitHub Desktop.
AngularJS MessageService Controller Usage Example 1
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
angular.module('idleworx-message-service') | |
.controller('ControllerDemo',['$scope','MessageService',function($scope,MessageService){ | |
MessageService.init($scope); //1st thing inside a controller, call the init() method | |
/* | |
Then anywhere inside your controller you need to write a message use the message service methods. | |
Don't forget to pass in the current scope. | |
*/ | |
MessageService.info($scope,'Info Message'); | |
MessageService.warn($scope,'Warning Message'); | |
MessageService.error($scope,'Error Message'); | |
MessageService.success($scope,'Success Message'); | |
MessageService.debug($scope,'Debug Message',{id:1,name:'My debug message'}); //allows you to pass in an additional object that will be displayed as JSON as well | |
//MessageService.clear($scope); //clear all messages on this scope. You can call this programatically, or by hooking it up to a $scope method | |
}]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment