File
Implements
Metadata
selector |
common-xicon-button |
styleUrls |
./xicon-button.component.scss |
templateUrl |
./xicon-button.component.html |
label
|
Type : string
|
|
Label to use for accessibility.
|
Outputs
click
|
Type : EventEmitter<any>
|
|
clickEvent
|
Type : EventEmitter<any>
|
|
import { Component, Input, Output, EventEmitter, OnInit } from '@angular/core';
import { MoHCommonLibraryError } from '../../../helpers/library-error';
@Component({
selector: 'common-xicon-button',
templateUrl: './xicon-button.component.html',
styleUrls: ['./xicon-button.component.scss']
})
export class XiconButtonComponent implements OnInit {
/**
* Label to use for accessibility.
* @required
*/
@Input() label: string;
/**
* @deprecated - Remove at breaking change and go to (click)
*/
@Output() clickEvent: EventEmitter<any> = new EventEmitter<any>();
@Output() click: EventEmitter<any> = new EventEmitter<any>();
constructor() { }
ngOnInit() {
if (!this.label) {
const msg = `common-xicon-button initialized without label. You MUST supply a label attribute for accessibility.
e.g. <common-xicon-button label='Remove Spouse'>
`; // Intentional to create a blank line between our error and stack trace.
throw new MoHCommonLibraryError(msg);
}
}
onBtnClick() {
this.clickEvent.emit();
this.click.emit();
}
}
<button class="close d-inline-block text-danger x-icon--close"
(click)="onBtnClick()"
type="button"
[attr.title]="label"
[attr.aria-label]="label">
<i class="fa fa-times-circle" aria-hidden="true"></i>
</button>
Legend
Html element with directive