I am working with angular2 toaster in angular2 application. on application start i am getting below error .
my app_module is below :
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { FormsModule } from '@angular/forms';
import { RouterModule } from '@angular/router';
import { HttpModule } from '@angular/http';
import { ReactiveFormsModule } from '@angular/forms';
import { ToasterModule, ToasterService} from 'angular2-toaster';
import { AppComponent } from './app.component';
@NgModule({
imports: [
BrowserModule,
FormsModule,
AppRoutingModule,
HttpModule,
ToasterModule
],
declarations: [AppComponent, HomeComponent,
CategoryListComponent, ConsultSotiComponent,
HeaderComponent, FooterComponent],
providers: [CategoryListService, LeadService,
LookUpDetailsService, CompanyService, ConsultSotiService, ToasterService],
bootstrap: [AppComponent]
})
export class AppModule { }
and i have bootstrap this module also.
My app.component is below:
import { Component } from '@angular/core';
import { OnInit } from '@angular/core';
import { TranslateService } from './translate/translate.service';
import { ToasterService} from 'angular2-toaster';
@Component({
selector: 'mp-app',
providers: [ToasterService],
template: `<div>
<toaster-container [toasterconfig]="config1"></toaster-container>
<button (click)="popToast()">pop toast</button><br/>
</div>`
})
export class AppComponent implements OnInit {
title = 'Enterprise MarketPlace';
public translatedText: string;
public supportedLanguages: any[];
constructor(private _translate: TranslateService, private toasterService: ToasterService) {
this.popToast();
}
popToast() {
this.toasterService.pop('success', 'Args Title', 'Args Body');
}
This results in a No Toaster Containers have been initialized to receive toasts
error.