File tree 2 files changed +26
-15
lines changed
app/ui-category/tab-view/binding-tab-view-items
2 files changed +26
-15
lines changed Original file line number Diff line number Diff line change 1
1
<!-- >> binding-tab-view-html -->
2
2
< TabView [(ngModel)] ="tabSelectedIndex " selectedColor ="#FF0000 " iosIconRenderingMode ="alwaysOriginal " sdkExampleTitle sdkToggleNavButton >
3
- < StackLayout *tabItem ="{title: 'Profile', iconSource: 'res://icon'} " >
4
- < ListView [items] ="items ">
5
- < ng-template let-item ="item ">
6
- < Label [text] ="item.itemDesc "> </ Label >
7
- </ ng-template >
8
- </ ListView >
3
+ < StackLayout *tabItem ="{title: 'Profile', iconSource: 'res://icon'} ">
4
+ < StackLayout >
5
+ < Label [text] ="'Profile Tab (tabSelectedIndex = '+ tabSelectedIndex +')' " class ="h2 m-t-16 text-center " textWrap ="true "> </ Label >
6
+ < Button text ="Change Tab via ngModel " (tap) ="changeTab() " class ="btn btn-primary btn-active "> </ Button >
7
+ </ StackLayout >
9
8
</ StackLayout >
10
9
< StackLayout *tabItem ="{title: 'Stats'} ">
11
- < Label text ="Second tab item "> </ Label >
10
+ < StackLayout >
11
+ < Label [text] ="'Stats Tab (tabSelectedIndex = '+ tabSelectedIndex +')' " class ="h2 m-t-16 text-center " textWrap ="true "> </ Label >
12
+ < Button text ="Change Tab via ngModel " (tap) ="changeTab() " class ="btn btn-primary btn-active "> </ Button >
13
+ </ StackLayout >
12
14
</ StackLayout >
13
15
< StackLayout *tabItem ="{title: 'Settings'} ">
14
- < Label text ="Third tab item "> </ Label >
16
+ < StackLayout >
17
+ < Label [text] ="'Settings Tab (tabSelectedIndex = '+ tabSelectedIndex +')' " class ="h2 m-t-16 text-center " textWrap ="true "> </ Label >
18
+ < Button text ="Change Tab via ngModel " (tap) ="changeTab() " class ="btn btn-primary btn-active "> </ Button >
19
+ </ StackLayout >
15
20
</ StackLayout >
16
21
</ TabView >
17
22
<!-- << binding-tab-view-html -->
Original file line number Diff line number Diff line change 1
- // >> binding-tab-view-code
1
+
2
2
import { Component } from "@angular/core" ;
3
3
import { StackLayout } from "ui/layouts/stack-layout" ;
4
4
5
5
import { TabView , SelectedIndexChangedEventData , TabViewItem } from "ui/tab-view" ;
6
6
7
7
export class DataItem {
8
- constructor ( public itemDesc : string ) { }
8
+ constructor ( public itemDesc : string ) { }
9
9
}
10
10
11
11
@Component ( {
12
12
moduleId : module . id ,
13
13
templateUrl : "./binding-tab-view-items.component.html" ,
14
14
} )
15
15
export class BindingTabViewItemsComponent {
16
- public items : Array < DataItem > ;
16
+ // >> binding-tab-view-code
17
17
public tabSelectedIndex : number ;
18
18
19
19
constructor ( ) {
20
20
this . tabSelectedIndex = 1 ;
21
- this . items = new Array < DataItem > ( ) ;
22
- for ( let i = 0 ; i < 5 ; i ++ ) {
23
- this . items . push ( new DataItem ( "item " + i ) ) ;
21
+ }
22
+
23
+ changeTab ( ) {
24
+ if ( this . tabSelectedIndex === 0 ) {
25
+ this . tabSelectedIndex = 1 ;
26
+ } else if ( this . tabSelectedIndex === 1 ) {
27
+ this . tabSelectedIndex = 2 ;
28
+ } else if ( this . tabSelectedIndex === 2 ) {
29
+ this . tabSelectedIndex = 0 ;
24
30
}
25
31
}
32
+ // << binding-tab-view-code
26
33
}
27
- // << binding-tab-view-code
You can’t perform that action at this time.
0 commit comments