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

Style does not work in ErrorHandler #91

Open
levinhtxbt opened this issue Oct 1, 2017 · 4 comments
Open

Style does not work in ErrorHandler #91

levinhtxbt opened this issue Oct 1, 2017 · 4 comments

Comments

@levinhtxbt
Copy link

levinhtxbt commented Oct 1, 2017

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

@VlSuslov
Copy link

VlSuslov commented Oct 5, 2017

Try to run 'webpack --config webpack.config.vendor.js' in command line. If you are working with ASP NET Core it doesn`t run webpack with this config automatically.

@levinhtxbt
Copy link
Author

I tried but not working

@erickpazzim
Copy link

Try to add @import '~ng2-toasty/bundles/style-bootstrap.css'; in your styles.css

@satishkayada
Copy link

satishkayada commented Mar 16, 2019

I have the same problem. stuck for a long time. Webpack is not command supported. I have followed Mosh Madani tutorial for learning from udamy.

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

4 participants