Skip to content

Wrapper around flashmessages #48

Description

@yanickvanbarneveld

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions