Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_this._flashMessagesService.grayOut is not a function #21

Open
denzelvb opened this issue May 3, 2017 · 9 comments
Open

_this._flashMessagesService.grayOut is not a function #21

denzelvb opened this issue May 3, 2017 · 9 comments

Comments

@denzelvb
Copy link

denzelvb commented May 3, 2017

I imported everything, ng-serve does not give any errors,

but the moment I call a function of this._flashMessagesService I get an error saying the following:

_this._flashMessagesService.grayOut is not a function

or

_this._flashMessagesService.show is not a function

@moff
Copy link
Owner

moff commented May 3, 2017

@denzelvb are you sure you've imported module properly?

@mterczynski
Copy link

mterczynski commented Jul 26, 2017

I got the same (or similar) issue now, although flash messages work well in my other project.
My problem is that every new instance of FlashMessagesService is an empty object (doesn't matter if I use DI or create new instance manually).

Some parts of one of my components code:

import { FlashMessagesService } from 'angular2-flash-messages';    

constructor(private flashMessageService: FlashMessagesService) {
}

ngOnInit() {
   console.log(new FlashMessagesService())
   console.log(this.flashMessageService);
}

Console logs are:

image

If I find a solution, I will let you know.

@amirensit
Copy link

amirensit commented Jul 27, 2017

same problem.
I think it needs instantiation of class FlashMessagesService

@Senegal
Copy link

Senegal commented Nov 21, 2017

I faced same issue.
Any updated on it?

@moff
Copy link
Owner

moff commented Nov 21, 2017

@Senegal I've just uploaded new version of the package to NPM. Update and import the package with .forRoot() - check update to README.md

Check if it works properly now and let me know. Thanks!

@Senegal
Copy link

Senegal commented Nov 21, 2017

@moff nice work, thank you! btw, I needed to upgrade to angular 5.

did you try build it in production? is everything ok?

@jbistis
Copy link

jbistis commented Jan 6, 2018

Reinstalled angular2-flash-messages using npm
app.module.ts has:
import { FlashMessagesModule } from 'angular2-flash-messages';
imports:[] has
FlashMessagesModule.forRoot()
component has
import { FlashMessagesService } from 'angular2-flash-messages';
constructor has:
constructor(
private authService: AuthService,
private router: Router,
private flashMessagesService: FlashMessagesService
) { }

onSubmit() {
this.authService.signin(this.email, this.password)
.then((res) => {
this.flashMessagesService.show('You are signed in', {
cssClass: 'alert-success', timeout: 4000
});
this.router.navigate(['/']);
})
.catch((err) => {
this.flashMessagesService.show(err.message, {
cssClass: 'alert-danger', timeout: 4000
});
this.router.navigate(['/signin']);
});
}

...still getting console error _this.flashMessagesService.show is not a function
Any ideas?

@pranaysand
Copy link

pranaysand commented Jan 26, 2018

I have faced the similar issue. I forgot to insert my selector into the html file I want it to show.
Please add this in your HTML, mine was app.component.html as it was an alert.

@xuejmnet
Copy link

xuejmnet commented Apr 27, 2018

<app-navbar></app-navbar>
<div class="container">
  <flash-messages></flash-messages> //this 
  <router-outlet></router-outlet>
</div>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants