import {Directive, View, CSSClass, onInit, ElementRef} from 'angular2/angular2'; import {IonicConfig} from '../../config/config'; import {IonicComponent} from '../../config/annotations'; import {Ion} from '../ion'; import {Platform} from '../../platform/platform'; /* 'home': { ios: ['ion-ios-home', 'ion-ios-home-outline'], md: 'ion-md-home' } 1-for-1 swap Map of stuff that's 1-for-1 Always use the same no matter what Cuz it's not in the map of 1-for-1's Different between modes Used different attributes Ionicons SVG ...ios... ...md... Custom SVG File Custom Font Icon */ @Directive({ selector: 'icon', properties: [ 'name', ], host: { '[attr.aria-label]': 'label', 'role': 'img' }, lifecycle: [onInit] }) export class IconDirective { constructor(elementRef: ElementRef) { this.ele = elementRef.nativeElement; } onInit() { if (this.name) { this.ele.classList.add(this.name); this.label = this.name.replace('ion-', '').replace('ios-', '').replace('md-', '').replace('-', ''); } } } @IonicComponent({ selector: 'ion-icon', properties: [ 'md', 'ios' ], host: { 'mode': 'mode' } }) @View({ template: '', directives: [CSSClass] }) export class Icon extends Ion { constructor(elementRef: ElementRef, ionicConfig: IonicConfig) { super(elementRef, ionicConfig); } onIonInit() { this.iconClass = this.ios; console.log('ICON', this.mode); setTimeout(() => { console.log('MODE', this.mode); }); } }