-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jon Zgoda
authored and
Jon Zgoda
committed
Jan 27, 2017
1 parent
6cadecb
commit 503bf01
Showing
3 changed files
with
57 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,67 @@ | ||
import {Component} from "@angular/core"; | ||
import {RouterExtensions} from "nativescript-angular"; | ||
import {ActivatedRoute} from "@angular/router"; | ||
|
||
@Component({ | ||
selector: "my-app", | ||
template: "<page-router-outlet></page-router-outlet>" | ||
}) | ||
export class AppComponent {} | ||
|
||
@Component({ | ||
selector: "my-tabs", | ||
template: `<GridLayout height="60" columns="25*, 25*, 25*, 25*"> | ||
<GridLayout col="0" horizontalAlignment="center" (tap)="setTab(0)"> | ||
<Label text="Tab 1" [ngClass]="{'tab-selected': selected === 0}"></Label> | ||
</GridLayout> | ||
<GridLayout col="1" horizontalAlignment="center" (tap)="setTab(1)"> | ||
<Label text="Tab 2" [ngClass]="{'tab-selected': selected === 1}"></Label> | ||
</GridLayout> | ||
<GridLayout col="2" horizontalAlignment="center" (tap)="setTab(2)"> | ||
<Label text="Tab 3" [ngClass]="{'tab-selected': selected === 2}"></Label> | ||
</GridLayout> | ||
<GridLayout col="3" horizontalAlignment="center" (tap)="setTab(3)"> | ||
<Label text="Tab 4" [ngClass]="{'tab-selected': selected === 3}"></Label> | ||
</GridLayout> | ||
</GridLayout>` | ||
}) | ||
export class MyTabs { | ||
selected: number = 0; | ||
|
||
constructor(private routerExtensions: RouterExtensions) {} | ||
|
||
setTab(tab: number): void { | ||
if (tab != this.selected) { | ||
this.selected = tab; | ||
this.routerExtensions.navigate(["/main/tab/" + tab], { clearHistory: true }); | ||
} | ||
} | ||
} | ||
|
||
@Component({ | ||
selector: "main", | ||
template: `<GridLayout> | ||
<TabView> | ||
<GridLayout *tabItem="{title: 'Tab 1'}"> | ||
<tab-1-component></tab-1-component> | ||
</GridLayout> | ||
<GridLayout *tabItem="{title: 'Tab 2'}"> | ||
<tab-2-component></tab-2-component> | ||
</GridLayout> | ||
</TabView> | ||
template: `<GridLayout rows="*, auto"> | ||
<GridLayout row="0"> | ||
<router-outlet></router-outlet> | ||
</GridLayout> | ||
<GridLayout row="1" backgroundColor="#5f9ea0"> | ||
<my-tabs></my-tabs> | ||
</GridLayout> | ||
</GridLayout>` | ||
}) | ||
export class MainComponent {} | ||
|
||
|
||
@Component({ | ||
selector: "tab-1-component", | ||
template: `<page-router-outlet></page-router-outlet>` | ||
}) | ||
export class Tab1Component {} | ||
|
||
@Component({ | ||
selector: "tab-1-child", | ||
template: `<GridLayout> | ||
<Label text="Tab 1"></Label> | ||
selector: "tab-component", | ||
template: `<GridLayout horizontalAlignment="center"> | ||
<Label [text]="'Tab ' + (tab)"></Label> | ||
</GridLayout>` | ||
}) | ||
export class Tab1Child {} | ||
export class TabComponent { | ||
tab: number; | ||
|
||
@Component({ | ||
selector: "tab-2-component", | ||
template: `<GridLayout> | ||
<Label text="Tab 2"></Label> | ||
</GridLayout>` | ||
}) | ||
export class Tab2Component {} | ||
constructor(private activatedRoute: ActivatedRoute) { | ||
this.activatedRoute.params.subscribe(params => this.tab = parseInt(params['tab']) + 1); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters