8000 Style does not work in ErrorHandler · Issue #91 · akserg/ng2-toasty · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Style does not work in ErrorHandler  #91
Open
@levinhtxbt

Description

@levinhtxbt

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:

Image

  • Angular : 4.2.5
  • Webpack: 2.5.1

Could you give me a way to fix. Thanks

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

      0