projects/rebirth-ng/src/lib/alert-box/alert-box.component.ts
changeDetection | ChangeDetectionStrategy.OnPush |
exportAs | alertBox |
selector | re-alert-box |
styleUrls | alert-box.component.scss |
templateUrl | ./alert-box.component.html |
Methods |
|
Inputs |
Outputs |
constructor(rebirthNGConfig: RebirthNGConfig)
|
||||||
Parameters :
|
closable
|
Type: |
cssClass
|
Type: |
removeIcon
|
Type: |
type
|
Type:
Default value: |
close
|
$event type: EventEmitter
|
closeBox |
closeBox()
|
Returns :
void
|
Private onCloseBox |
onCloseBox()
|
Returns :
void
|
import { Component, Input, Output, EventEmitter, ChangeDetectionStrategy } from '@angular/core';
import { RebirthNGConfig } from '../rebirth-ng.config';
@Component({
selector: 're-alert-box',
templateUrl: './alert-box.component.html',
styleUrls: ['./alert-box.component.scss'],
exportAs: 'alertBox',
changeDetection: ChangeDetectionStrategy.OnPush
})
export class AlertBoxComponent {
@Input() removeIcon: string;
@Input() type: 'success' | 'info' | 'warning' | 'danger' = 'info';
@Input() cssClass: string;
@Input() closable: boolean;
@Output() close = new EventEmitter<any>();
constructor(rebirthNGConfig: RebirthNGConfig) {
this.type = <any>rebirthNGConfig.alertBox.type;
this.closable = rebirthNGConfig.alertBox.closable;
this.removeIcon = rebirthNGConfig.alertBox.removeIcon;
}
closeBox() {
this.onCloseBox();
}
private onCloseBox() {
this.close.emit(this);
}
}
<div class="alert alert-{{type}} {{cssClass}}" [ngClass]="{'alert-dismissible': closable}" role="alert">
<button type="button" class="close" data-dismiss="alert" aria-label="Close" *ngIf="closable" (click)="closeBox()">
<span aria-hidden="true" class="alert-remove-icon {{removeIcon}}"></span>
</button>
<ng-content></ng-content>
</div>