Docs
Docs
504

Toasts are a component available in Angular Material.

Since most implementations require a success and an error toast, this repository provides you with pre-configured ToastService that you can easily adjust to fit your needs.

This service allows you to open a success toast and an error toast.
The error toast is also automatically displayed when the API encounters a validation error (using restangular's error interceptor).

While this service has a default delay, position and action text, you can easily change them in angular/services/toast.service.js. You can also add custom methods.

export class PostsController(){
  constructor(ToastService){
      'ngInject';
    	this.ToastService = ToastService;
  }
  
  success(){
		this.ToastService.show('Post added successfully!');
	}
    
  error(){
		this.ToastService.error('Connection interrupted!');
	}
}