Skip to content

Commit

Permalink
feat(demo): access static tabs sample (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
rafalkasa authored and valorkin committed Feb 28, 2017
1 parent 4df17c7 commit 63c64e0
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ addons:
- ubuntu-toolchain-r-test
# required by node-gyp to build some packages
packages:
- g++-4.8
- g++-4.8
34 changes: 25 additions & 9 deletions demo/src/app/components/+tabs/demos/basic/basic.html
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
<tabset>
<tab heading="Static title">Static content</tab>
<tab (select)="alertMe()">
<template tabHeading>
<i class="glyphicon glyphicon-bell"></i> Alert!
</template>
I've got an HTML heading, and a select callback. Pretty cool!
</tab>
</tabset>
<div>
<p>Access to static tab from component</p>
<p>
<button type="button" class="btn btn-primary btn-sm" (click)="selectTab(1)">Select second tab</button>
<button type="button" class="btn btn-primary btn-sm" (click)="selectTab(2)">Select third tab</button>
</p>
<p>
<button type="button" class="btn btn-primary btn-sm" (click)="disableEnable()">
Enable / Disable third tab
</button>
</p>
<hr/>
<tabset #staticTabs>
<tab heading="Static title">Static content</tab>
<tab heading="Static Title 1">Static content 1</tab>
<tab heading="Static Title 2">Static content 2</tab>
<tab heading="Static Title 3" removable="true">Static content 3</tab>
<tab (select)="alertMe()">
<template tabHeading>
<i class="glyphicon glyphicon-bell"></i> Alert!
</template>
I've got an HTML heading, and a select callback. Pretty cool!
</tab>
</tabset>
</div>

13 changes: 12 additions & 1 deletion demo/src/app/components/+tabs/demos/basic/basic.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import { Component } from '@angular/core';
import { Component, ViewChild } from '@angular/core';
import { TabsetComponent } from 'ng2-bootstrap';

@Component({
selector: 'demo-tabs-basic',
templateUrl: './basic.html'
})
export class DemoTabsBasicComponent {

@ViewChild('staticTabs') staticTabs: TabsetComponent;

public alertMe(): void {
setTimeout(function (): void {
alert('You\'ve selected the alert tab!');
});
}

selectTab(tab_id: number) {
this.staticTabs.tabs[tab_id].active = true;
}

disableEnable() {
this.staticTabs.tabs[2].disabled = ! this.staticTabs.tabs[2].disabled
}
}
2 changes: 1 addition & 1 deletion karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ module.exports = function (config) {
}

config.set(configuration);
};
};

0 comments on commit 63c64e0

Please sign in to comment.