moff / angular2-flash-messages

Angular 2 flash messages module
52 stars 21 forks source link

Wrapper around flashmessages #48

Open yanickvanbarneveld opened 5 years ago

yanickvanbarneveld commented 5 years ago

Hi,

I have a service around the flash messages service as following:

import { Injectable } from '@angular/core';
import { FlashMessagesService } from 'angular2-flash-messages';

@Injectable()
export class MessagesService {
   constructor(private flashMessagesService: FlashMessagesService) {}

   public show(message: string, cssClass: string = 'success') {
      this.flashMessagesService.show(message, {
         cssClass: cssClass,
         closeOnClick: true,
         showCloseBtn: true,
         timeout: 5000
      });
   }
}

And in my component as following:

constructor(
      private messages: MessagesService,
){}

ngOnInit() {
      this.messages.show('Test', 'success');
}

But when this runs I get the following error: ManagementLocationsComponent.html:1 ERROR TypeError: this.flashMessagesService.show is not a function

Any ideas what is going wrong over here?

Kind regards, Yanick