Skip to content

Instantly share code, notes, and snippets.

@matheusmurta
Created May 4, 2018 13:47
Show Gist options
  • Select an option

  • Save matheusmurta/f8aa1856c8b568d1cac6ac5c5e184659 to your computer and use it in GitHub Desktop.

Select an option

Save matheusmurta/f8aa1856c8b568d1cac6ac5c5e184659 to your computer and use it in GitHub Desktop.
import { Component, ViewContainerRef } from '@angular/core';
import { ToastsManager } from 'ng2-toastr/ng2-toastr';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent {
constructor(public toastr: ToastsManager, vcr: ViewContainerRef) {
this.toastr.setRootViewContainerRef(vcr);
}
showSuccess() {
this.toastr.success('Operação realizada com sucesso !', 'Success!');
}
showError() {
this.toastr.error('Erro ao realizar a operação!', 'Oops!');
}
showWarning() {
this.toastr.warning('Preencha os campos corretamente.', 'Alerta!');
}
showInfo() {
this.toastr.info('Informação para você');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment