ngx-toastr creates and empty 'ng-component' elemnt
See original GitHub issueWhen trying to create some toasts, the rendered elements are like the following:
I’m trying to use ngx-toaster in a custom component.
Declaring module:
import { NgModule, ModuleWithProviders } from '@angular/core';
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
import { ToastrModule } from 'ngx-toastr';
import { UrlsComponent } from './urls.component';
import { ToastComponent } from './toast.component';
import { AuthService } from './auth/auth.service';
import { AuthInterceptor } from './auth/auth.interceptor';
import { ExchangeService } from './exchange/exchange.service';
import { ExchangeApiService } from './exchange-api/exchange-api.service';
@NgModule({
imports: [
HttpClientModule,
ToastrModule.forRoot({
toastComponent: ToastComponent // added custom toast!
})
],
entryComponents: [ToastComponent],
declarations: [
UrlsComponent,
ToastComponent
],
exports: [
UrlsComponent
]
})
export class ApiClientModule {
static forRoot(): ModuleWithProviders {
return {
ngModule: ApiClientModule,
providers: [
{
provide: HTTP_INTERCEPTORS,
useClass: AuthInterceptor,
multi: true
},
AuthService,
ExchangeService,
ExchangeApiService,
ToastComponent
]
};
}
}
And the custom component:
import { Component } from '@angular/core';
import { ToastrService } from 'ngx-toastr';
@Component({
template: ''
})
export class ToastComponent {
constructor(private toastr: ToastrService) { }
addLodingToast() {
console.log('addLodingToast');
this.toastr.info('Please wait ...', 'Loading Data', {
disableTimeOut: true
});
}
addErrorLodingToast() {
this.addErrorToast('Error', 'Failed to load data.');
}
clearAllToasts() {
this.toastr.clear();
}
}
Issue Analytics
- State:
- Created 5 years ago
- Reactions:1
- Comments:8 (1 by maintainers)
Top Results From Across the Web
ngx-toastr, Toast not showing in Angular 7 - Stack Overflow
I wanted to include ngx-toastr to send notifications to users but it isn't working as expected. When I trigger a toast nothing happens,...
Read more >ngx-toastr - UNPKG
The CDN for ngx-toastr. ... /toastr.module.ts","ng://ngx-toastr/toastr/toast-noanimation.component.ts"] ... Object.create(b) : (__.prototype = b.prototype, ...
Read more >ngx-toastr - npm
Start using ngx-toastr in your project by running `npm i ngx-toastr`. ... Toast Component Injection without being passed ViewContainerRef ...
Read more >ngx-toastr@16.0.1 - jsDocs.io
This method returns the overlay container element. It will lazily create the element the first time it is called to facilitate using the ......
Read more >Configuring options in Angular Toast component - Syncfusion
Toast can be created with the notification message. The message contains title and content of the Toasts. Title and contents are adaptable in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
You’re both missing BrowserAnimationsModule
You are right. I’ve use it in an interceptor before and had no problem.
OK I’ve got the point. thank you.