File

src/app/shared/components/toast/toast.component.ts

Metadata

host {
}
selector app-toasts
templateUrl ./toast.component.html

Index

Properties
Methods

Constructor

constructor(toastService: ToastService)
Parameters :
Name Type Optional
toastService ToastService No

Methods

isTemplate
isTemplate(toast)
Parameters :
Name Optional
toast No
Returns : boolean

Properties

Public toastService
Type : ToastService
import {Component, TemplateRef} from '@angular/core';
import {ToastService} from '@app/shared/services/toast.service';

@Component({
  selector: 'app-toasts',
  templateUrl: './toast.component.html',
  host: {'[class.ngb-toasts]': 'true'}
})
export class ToastComponent {
  constructor(public toastService: ToastService) {}

  isTemplate(toast) { return toast.textOrTpl instanceof TemplateRef; }
}
<ngb-toast class="fixed-bottom"
  *ngFor="let toast of toastService.toasts"
  [header]="toast.headertext"
  [class]="toast.classname"
  [autohide]="toast.autohide"
  [delay]="toast.delay || 5000"
  (hide)="toastService.remove(toast)">
  <ng-template [ngIf]="isTemplate(toast)" [ngIfElse]="text">
    <ng-template [ngTemplateOutlet]="toast.textOrTpl"></ng-template>
  </ng-template>
  <ng-template #text>{{ toast.textOrTpl }}</ng-template>
</ngb-toast>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""