src/modal/modal-header.component.ts
Inputs
Example :<cds-modal-header>Header text</cds-modal-header>Outputs
Example :<cds-modal-header (closeSelect)="closeModal()">Header text</cds-modal-header>| selector | cds-modal-header, ibm-modal-header |
| template | |
Properties |
Methods |
|
Inputs |
Outputs |
constructor(i18n: I18n)
|
||||||
|
Defined in src/modal/modal-header.component.ts:79
|
||||||
|
Parameters :
|
| closeLabel | |
Type : any
|
|
Default value : this.i18n.get().MODAL.CLOSE
|
|
|
Defined in src/modal/modal-header.component.ts:57
|
|
|
Accessible label for the header close button.
Defaults to the |
|
| decorator | |
Type : TemplateRef<any>
|
|
|
Defined in src/modal/modal-header.component.ts:66
|
|
|
Experimental: Optional decorator (e.g. AI label). |
|
| showCloseButton | |
Type : boolean
|
|
Default value : true
|
|
|
Defined in src/modal/modal-header.component.ts:61
|
|
|
Set to |
|
| theme | |
Type : string
|
|
Default value : "default"
|
|
|
Defined in src/modal/modal-header.component.ts:52
|
|
| closeSelect | |
Type : EventEmitter
|
|
|
Defined in src/modal/modal-header.component.ts:71
|
|
|
To emit the event of clicking on the close icon within the modal. |
|
| Public onClose |
onClose()
|
|
Defined in src/modal/modal-header.component.ts:86
|
|
Handles click for the close icon button within the
Returns :
void
|
| buttonAttributes |
Type : object
|
Default value : {
"aria-label": this.i18n.get().MODAL.CLOSE
}
|
|
Defined in src/modal/modal-header.component.ts:77
|
| buttonNgClass |
Type : object
|
Default value : {
"cds--modal-close": true
}
|
|
Defined in src/modal/modal-header.component.ts:73
|
import {
Component,
Output,
EventEmitter,
Input,
TemplateRef
} from "@angular/core";
import { I18n } from "carbon-components-angular/i18n";
/**
* ***Inputs***
* ```html
* <cds-modal-header>Header text</cds-modal-header>
* ```
*
* ***Outputs***
* ```html
* <cds-modal-header (closeSelect)="closeModal()">Header text</cds-modal-header>
* ```
*/
@Component({
selector: "cds-modal-header, ibm-modal-header",
template: `
<header class="cds--modal-header {{theme}}">
<ng-content></ng-content>
<ng-container *ngIf="decorator">
<div class="cds--modal--inner__decorator">
<ng-template [ngTemplateOutlet]="decorator"></ng-template>
</div>
</ng-container>
<div class="cds--modal-close-button">
<cds-icon-button
*ngIf="showCloseButton"
type="button"
[buttonNgClass]="buttonNgClass"
[buttonAttributes]="buttonAttributes"
align="left"
[description]="closeLabel"
(click)="onClose()">
<svg cdsIcon="close" size="20" class="cds--modal-close__icon"></svg>
</cds-icon-button>
</div>
</header>
`
})
export class ModalHeader {
/**
* @deprecated since v5
* Sets the style on the modal heading based on its category.
*/
@Input() theme = "default";
/**
* Accessible label for the header close button.
* Defaults to the `MODAL.CLOSE` value from the i18n service.
*/
@Input() closeLabel = this.i18n.get().MODAL.CLOSE;
/**
* Set to `false` to hide the close button.
*/
@Input() showCloseButton = true;
/**
* **Experimental**: Optional decorator (e.g. AI label).
*/
@Input() decorator: TemplateRef<any>;
/**
* To emit the event of clicking on the close icon within the modal.
*/
@Output() closeSelect = new EventEmitter();
buttonNgClass = {
"cds--modal-close": true
};
buttonAttributes = {
"aria-label": this.i18n.get().MODAL.CLOSE
};
constructor(protected i18n: I18n) {}
/**
* Handles click for the close icon button within the `Modal`.
*/
public onClose() {
this.closeSelect.emit();
}
}