Cómo usar SnackBar en el servicio para usar en cada componente en Angular 2
Tengo un snack bar que funciona, pero solo está en cada componente, quiero agregarlo a mi servicio, así que lo llamaré. Esta es mi muestra en micomponent.ts
import { MdSnackBar, MdSnackBarRef } from '@angular/material';
...
export class EmployeeListComponent implements OnInit {
public toastRef: MdSnackBarRef<any>;
constructor(private _activatedRoute:ActivatedRoute,private router: Router, private http:PMISHttpService, private toast: MdSnackBar) {
ngOnInit() {
this.notify('test');
}
...
notify (text: string) {
this.toastRef = this.toast.open(text, null);
setTimeout(() => {
this.toastRef.dismiss();
}, 5000);
}
...
}