icon name property

This commit is contained in:
Adam Bradley
2015-05-31 21:33:10 -05:00
parent f554cc51df
commit dfa158094b
2 changed files with 17 additions and 6 deletions

View File

@@ -1,11 +1,21 @@
import {Component, Directive} from 'angular2/src/core/annotations_impl/annotations';
import {Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
import {ElementRef} from 'angular2/src/core/compiler/element_ref';
@Directive({
selector: 'ion-icon,ionicon,icon'
selector: 'icon',
properties: [
'name'
],
lifecycle: [onInit]
})
export class Icon {
constructor() {
//ngEle.domElement.setAttribute('aria-hidden', 'hidden')
constructor(elementRef: ElementRef) {
this.domElement = elementRef.domElement;
}
onInit() {
if (this.name) {
this.domElement.classList.add(this.name);
}
}
}

View File

@@ -8,6 +8,7 @@ import {NgFor} from 'angular2/angular2';
import {IonicComponent} from '../../config/component';
import {Tab} from './tab';
import {TabButton} from './tab-button';
import {Icon} from '../icon/icon';
@Component({
@@ -23,7 +24,7 @@ import {TabButton} from './tab-button';
<nav class="navbar-container tab-bar-container">
<div class="tab-bar">
<button *ng-for="#t of tabs" [tab]="t" class="tab-button">
<icon [class-name]="'tab-button-icon ' + t.tabIcon"></icon>
<icon [name]="t.tabIcon" class="tab-button-icon"></icon>
<span class="tab-button-text">{{t.tabTitle}}</span>
</button>
</div>
@@ -32,7 +33,7 @@ import {TabButton} from './tab-button';
<content></content>
</section>
`,
directives: [NgFor, TabButton]
directives: [NgFor, TabButton, Icon]
})
export class Tabs {
constructor(elementRef: ElementRef, loader: DynamicComponentLoader, injector: Injector) {