Skip to content

Commit 185a7bf

Browse files
Include new example for list picker
1 parent 36f2bf3 commit 185a7bf

File tree

5 files changed

+58
-3
lines changed

5 files changed

+58
-3
lines changed

Diff for: app/app.routes.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ import { ListViewAsyncPipeComponent } from "./listView/asyncPipeTemplate/async-p
1717
import { ListViewMainPageComponent } from "./listView/listViewMainPage/list-view-main-page";
1818
import { ListViewWithNestedTemplateComponent } from "./listView/nestedTemplate/list-view-nested-template";
1919

20+
import { ListPickerMainPageComponent } from "./listPicker/list-picker-main-page";
21+
import { ListPickerComponent } from "./listPicker/list-picker";
22+
2023
import { ModalTest, ModalTestWithPushStrategy, ModalContent } from "./modal/modal-dialogs/modal-dialog.component";
2124
import { ModalViewMainPageComponent } from "./modal/modal-view-main-page";
2225

@@ -26,10 +29,9 @@ import { NavigationOptionsComponent } from "./navigation-options/navigation-opti
2629
import { NavigationInfoComponent } from "./navigation-options/navigation-info.component";
2730
import { MainComponent } from "./main/main-page-router-outlet";
2831

29-
3032
export var routableComponents = [];
3133

32-
// Set isNavigatable: trueif the page is a mian page to other sub pages
34+
// Set isNavigatable: true if the page is a mian page to other sub pages
3335
export const routes = [
3436
routeEntry({ path: '', component: MainComponent, data: { title: "" } }),
3537
routeEntry({ path: '', component: ModalContent, data: { title: "" } }),
@@ -51,6 +53,9 @@ export const routes = [
5153
routeEntry({ path: 'listView/asyncPipeTemplate', component: ListViewAsyncPipeComponent, data: { title: "asyncPipeTemplate" } }),
5254
routeEntry({ path: 'listView/nestedTemplate', component: ListViewWithNestedTemplateComponent, data: { title: "nestedTemplate" } }),
5355

56+
routeEntry({ path: 'listPicker', component: ListPickerMainPageComponent, data: { title: "ListPicker", isNavigatable: true } }),
57+
routeEntry({ path: 'listPicker/list-picker', component: ListPickerComponent, data: { title: "ListPicker", isNavigatable: false } }),
58+
5459
routeEntry({ path: 'modal', component: ModalViewMainPageComponent, data: { title: "Modals", isNavigatable: true} }),
5560
routeEntry({ path: 'modal/modal-dialogs', component: ModalTest, data: { title: "modal" } }),
5661
routeEntry({ path: 'modal/modal-dialogs-push', component: ModalTestWithPushStrategy, data: { title: "modal(onPush)" } }),

Diff for: app/listPicker/list-picker-main-page.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Component } from "@angular/core";
2+
3+
@Component({
4+
selector: "main",
5+
template: `
6+
<StackLayout>
7+
<Button text="ListPicker" [nsRouterLink]="['/listPicker','list-picker']"></Button>
8+
</StackLayout>
9+
`,
10+
})
11+
export class ListPickerMainPageComponent { }

Diff for: app/listPicker/list-picker.css

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
.listPicker {
2+
color: green;
3+
background-color: black;
4+
}

Diff for: app/listPicker/list-picker.ts

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import { Component,Input, ChangeDetectionStrategy } from '@angular/core';
2+
3+
@Component({
4+
selector: 'list',
5+
styleUrls: ['./listPicker/list-picker.css'],
6+
template: `
7+
<StackLayout automationText="listPicker" >
8+
<ListPicker #picker class="listPicker"
9+
[items]="pokemons" [selectedIndex]="selectedIndex"
10+
(selectedIndexChange)="selectedIndexChanged(picker)">
11+
</ListPicker>
12+
</StackLayout>
13+
`,
14+
changeDetection: ChangeDetectionStrategy.OnPush
15+
})
16+
17+
export class ListPickerComponent {
18+
public pokemons: Array<string>;
19+
public picked: string;
20+
21+
private pokemonList = ["Bulbasaur", "Parasect", "Venonat", "Venomoth", "Diglett",
22+
"Dugtrio", "Meowth", "Persian", "Psyduck", "Arcanine", "Poliwrath", "Machoke"];
23+
24+
constructor() {
25+
this.pokemons = [];
26+
27+
for (let i = 0; i < this.pokemonList.length; i++) {
28+
this.pokemons.push(this.pokemonList[i]);
29+
}
30+
}
31+
32+
public selectedIndexChanged(picker) {
33+
console.log("picker selection: " + picker.selectedIndex);
34+
this.picked = this.pokemons[picker.selectedIndex];
35+
}
36+
}

Diff for: app/main/main-page-router-outlet.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import { Component } from "@angular/core";
2-
import { routes } from "../app.routes";
32
import * as platform from "platform";
43

54
@Component({

0 commit comments

Comments
 (0)