Files
Adam Bradley 123f3f31be icon aria
2015-05-31 21:45:28 -05:00

29 lines
573 B
JavaScript

import {Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
@Directive({
selector: 'icon',
properties: [
'name'
],
hostProperties: {
'label': 'attr.aria-label'
},
hostAttributes: {
'role': 'img'
},
lifecycle: [onInit]
})
export class Icon {
constructor(elementRef: ElementRef) {
this.domElement = elementRef.domElement;
}
onInit() {
if (this.name) {
this.domElement.classList.add(this.name);
this.label = this.name;
}
}
}