projects/ng-snotify/src/lib/components/buttons/buttons.component.ts
changeDetection | ChangeDetectionStrategy.OnPush |
encapsulation | ViewEncapsulation.None |
selector | ng-snotify-button |
templateUrl | ./buttons.component.html |
Methods |
Inputs |
constructor(service: SnotifyService)
|
||||||
Parameters :
|
toast | |
Type : SnotifyToast
|
|
Get buttons Array |
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>