Open
Description
Hi.
I have a problem when i try to implement ng2-toasty in a class that implements from ErroHandler. The toasts appeared but without any styles.
I have added 'ng2-toasty', 'ng2-toasty/bundles/style-bootstrap.css', in webpack.config.vendor.js.
If I call in component, everything is ok.
This is CustomErrorHandler:
import { Injectable } from '@angular/core';
import { ToastyService } from 'ng2-toasty';
import { ErrorHandler, NgZone } from "@angular/core";
@Injectable()
export class CustomErrorHandler implements ErrorHandler {
constructor(
private ngZone: NgZone,
private toastyService : ToastyService) {}
handleError(error : any) : void {
console.log(error);
this.ngZone.run(() => {
if (typeof(window) !== 'undefined') {
this
.toastyService
.error({
title: 'Error',
msg: 'An unexpected error happened',
theme: ' bootstrap',
showClose: true,
timeout: 5000
});
}
});
}
}
This is "app.module"
import { ErrorHandler } from '@angular/core';
import { CustomErrorHandler } from './services/app.error-handle';
....
import { ToastyModule} from 'ng2-toasty';
....
@NgModule({
declarations: [
AppComponent,
NavMenuComponent,
CounterComponent,
FetchDataComponent,
HomeComponent,
VehicleFormComponent
],
imports: [
CommonModule,
ToastyModule.forRoot(),
HttpModule,
FormsModule,
RouterModule.forRoot([
...
])
],
providers: [
{ provide: ErrorHandler, useClass: CustomErrorHandler },
VehicleService
]
})
export class AppModuleShared {
}
Screenshot:
- Angular : 4.2.5
- Webpack: 2.5.1
Could you give me a way to fix. Thanks
Metadata
Metadata
Assignees
Labels
No labels