File

projects/ng-snotify/src/lib/components/buttons/buttons.component.ts

Metadata

changeDetection ChangeDetectionStrategy.OnPush
encapsulation ViewEncapsulation.None
selector ng-snotify-button
templateUrl ./buttons.component.html

Index

Methods
Inputs

Constructor

constructor(service: SnotifyService)
Parameters :
Name Type Optional
service SnotifyService No

Inputs

toast
Type : SnotifyToast

Get buttons Array

Methods

remove
remove()

remove toast

Returns : void
import { ChangeDetectionStrategy, Component, Input, ViewEncapsulation } from '@angular/core';
import { SnotifyService } from '../../services/snotify.service';
import { SnotifyToast } from '../../models/snotify-toast.model';

@Component({
  selector: 'ng-snotify-button',
  templateUrl: './buttons.component.html',
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None
})

/**
 * Buttons component
 */
export class ButtonsComponent {
  /**
   * Get buttons Array
   */
  @Input() toast: SnotifyToast;
  constructor(private service: SnotifyService) {}

  /**
   * remove toast
   */
  remove() {
    this.service.remove(this.toast.id);
  }
}
<div class="snotifyToast__buttons">
  <button
    type="button"
    *ngFor="let button of toast.config.buttons"
    [ngClass]="{ 'snotifyToast__buttons--bold': button.bold }"
    (click)="button.action ? button.action(toast) : remove()"
  >
    {{ button.text }}
  </button>
</div>
Legend
Html element
Component
Html element with directive

result-matching ""

    No results matching ""