I'm using nebular for my project, and cannot find out how to get close button
of NbAlertComponent to actually close alert. By closing I mean to stop showing after clicking on close button
. I read documentation about alert component docs, but did not found an answer. Alert component can have property closable
, which adds close button, and can have event handler when clicked on it (close)="onClose()"
. I'm using it this way (angular 6):
// page.component.html
<nb-alert status="success" closable (close)="onClose()">
You have been successfully authenticated!
</nb-alert>
In page.component.ts, if I have a method onClose
, it fires every time I click on alert close button
, but how to actually close it?
// page.component.ts
onClose() {
// fires after each click on close button:
console.log('close button was clicked');
}
Here is some code from alert component related close functionality:
// alert.component.ts
/**
* Emits when chip is removed
* @type EventEmitter<any>
*/
// this is an instance of NbAlertComponent
this.close = new EventEmitter();
/**
* Emits the removed chip event
*/
NbAlertComponent.prototype.onClose = function () {
this.close.emit();
};