File

projects/ngx-toastn/src/lib/ngx-toast.component.ts

Description

A Toast component shows message with title and close button.

Metadata

selector ngx-toast
templateUrl ngx-toast.component.html

Index

Methods
Inputs
Outputs

Inputs

toast

Type: ToastData

Outputs

closeToast $event type: EventEmitter

Methods

close
close($event: any)

Event handler invokes when user clicks on close button. This method emit new event into ToastyContainer to close it.

Parameters :
Name Type Optional
$event any no
Returns : void
import { Component, Input, Output, EventEmitter } from '@angular/core';

import { ToastData } from './ngx-toastn.service';

/**
 * A Toast component shows message with title and close button.
 */
@Component({
  selector: 'ngx-toast',
  templateUrl: 'ngx-toast.component.html'
})
export class NgxToastComponent {

  @Input() toast: ToastData;
  @Output('closeToast') closeToastEvent = new EventEmitter();

  /**
   * Event handler invokes when user clicks on close button.
   * This method emit new event into ToastyContainer to close it.
   */
  close($event: any) {
    $event.preventDefault();
    this.closeToastEvent.next(this.toast);
  }
}
<div class="toast" [ngClass]="[toast.type, toast.theme]">
  <div *ngIf="toast.showClose" class="close-button" (click)="close($event)"></div>
  <div *ngIf="toast.title || toast.msg" class="toast-text">
    <span *ngIf="toast.title" class="toast-title" [innerHTML]="toast.title | safeHtml"></span>
    <br *ngIf="toast.title && toast.msg" />
    <span *ngIf="toast.msg" class="toast-msg" [innerHtml]="toast.msg | safeHtml"></span>
  </div>
</div>
Legend
Html element
Component
Html element with directive

results matching ""

    No results matching ""