scttcper / ngx-toastr

🍞 Angular Toastr
https://ngx-toastr.vercel.app
MIT License
2.52k stars 358 forks source link

ngx-toaster not imported in angular 17 #1011

Open ekta-rupareliya opened 10 months ago

ekta-rupareliya commented 10 months ago

if we install ngx-toaster and import in angular 17 then import in standalone component but not working

@Component({ selector: 'app-notification', standalone: true, imports: [PageTitleComponent, ToastrModule.forRoot()], templateUrl: './notification.component.html', styles: `` })

rickardaniel commented 10 months ago

I had the same problem, however i could solve. You should import providers: [ provideAnimations(), provideToastr(), ] In app.config.ts, in the app.component.ts you don't import nothing Now in your component where you call the toast, you should continue work as the same

prokopec-simon commented 10 months ago

Even with @rickardaniel 's tip I still get "Type 'EnvironmentProviders' is not assignable to type 'Provider'." error. Anyone has any tips on how to fix this? Thank you.

rickardaniel commented 10 months ago

I'm working with: Angular CLI : 17.0.8 Angular: 17.0.8 Node: 20.10.0 npm: 10.2.5 TypeScript: 5.2.2 ngx-toastr: ^17.0.2

You should add @import 'ngx-toastr/toastr'; in the file styles.scss, Also try to work the toast services in another file