An angular module wrapper service for the Foxandxss angular-toasts
bower install lf-angular-toastr
Include the following resources in your html file:
<link rel="stylesheet" href="bower_components/angular-toastr/dist/angular-toastr.css">
<script src="bower_components/angular-animate/angular-animate.js"></script>
<script src="bower_components/angular-toastr/dist/angular-toastr.tpls.js"></script>
<script src="bower_components/lf-angular-toastr/lf-angular-toastr.js"></script>
Add also to your Angular controller like below:
var myApp = angular.module('myApp', ['lf-toastr']);
myApp.controller('MyController', ['lfToastrService', function(lfToastrService) {
//call methods here as per API below
});
Below are the available methods and examples on how to use them
- thereAreOpenedToasts returns true if there are toasts, returns false otherwise
- Example:
if (lfToastrService.thereAreOpenedToasts() { ... do something ... }
- Example:
- clearToasts removes all opened toasts
- Example:
lfToastrService.clearToasts();
- Example:
- toastIsOpened returns true if a toast (defined by the message string) is opened, returns false otherwise
- Example:
if (lfToastrService.toastIsOpened('I love toasts') { ... do something ... }
- Example:
- openToast opens a toast, given a message string, a title string, and an optional config object
- Example:
lfToastrService.openToast('I love toasts', 'TOAST ME', {type: 'success'});
- Example:
- clearToast removes a toast, given a message string
- Example:
lfToastrService.removeToast('I love toasts');
- Example:
The default configuration used by lf-angular-toastr is shown below:
toastDefaultOptions = {
positionClass: 'toast-bottom-right',
tapToDismiss: false,
timeOut: 0,
extendedTimeOut: 0,
type: 'error'
};
This configuration can be modified by the optional config object passed into the method openToast().
Find more information on all the possible configuration options and usage examples here: Foxandxss angular-toasts