basic tabs

This commit is contained in:
Adam Bradley
2015-05-30 20:51:56 -05:00
parent 0bd6915a98
commit 0cb0a1c600
5 changed files with 106 additions and 59 deletions

View File

@ -0,0 +1,40 @@
import {Parent} from 'angular2/src/core/annotations_impl/visibility';
import {Directive, onInit} from 'angular2/src/core/annotations_impl/annotations';
import {View} from 'angular2/src/core/annotations_impl/view';
import {Tabs} from './tabs';
@Directive({
selector: '.tab-button',
properties: ['tab'],
hostProperties: {
'btnId': 'attr.id',
'ariaControls': 'attr.aria-controls',
'tab.isSelected': 'attr.aria-selected'
},
hostAttributes: {
'role': 'tab'
},
hostListeners: {
'^click': 'onClick($event)'
},
lifecycle: [onInit]
})
export class TabButton {
constructor(@Parent() tabs: Tabs) {
this.tabs = tabs;
}
onInit() {
this.btnId = 'tab-button-' + this.tab.id;
this.ariaControls = 'tab-content-' + this.tab.id;
}
onClick(ev) {
ev.stopPropagation();
ev.preventDefault();
this.tabs.selectTab(this.tab);
}
}