Skip to content

Commit 2b264c9

Browse files
# Conflicts: # app/binding/binding-page.html # app/binding/binding-page.ts # app/main/main-page-router-outlet.ts
2 parents 09ccd73 + 9a4f0a3 commit 2b264c9

File tree

3 files changed

+95
-1
lines changed

3 files changed

+95
-1
lines changed

app/binding/binding-page.html

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<StackLayout>
2+
<TextField hint="oneWayDataBinding" automationText="tfOneWayBinding" keyboardType="email" [text]="oneWayDataBinding" autocorrect="false" autocapitalizationType="none"></TextField>
3+
<TextField hint="twoWayDataBindingBanana" automationText="tfTwoWayBinding" keyboardType="email" [(ngModel)]="twoWayDataBinding" autocorrect="false" autocapitalizationType="none"></TextField>
4+
<TextField hint="" automationText="tfCurlyBracket" keyboardType="email" text="{{ curlyBracket }}" autocorrect="false" autocapitalizationType="none"></TextField>
5+
<Label automationText="lbCurlyBracketBinding" text='Label with curlyBaracket binding: {{ twoWayDataBinding }}'></Label>
6+
7+
<StackLayout orientation="horizontal">
8+
<Button (tap)="changeValues()" automationText="changeValues" text="update from code" ></Button>
9+
<Button (tap)="getValues()" automationText="getValues" text="get" width="80" height="40"></Button>
10+
</StackLayout>
11+
<TextView [text]="results" automationText="tvResults" textWrap="true"></TextView>
12+
</StackLayout>

app/modal/modal-dialog.component.ts

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import {Component, ChangeDetectionStrategy} from '@angular/core';
2+
import * as dialogs from "ui/dialogs";
3+
import {ModalDialogService, ModalDialogOptions, ModalDialogHost, ModalDialogParams} from "nativescript-angular/directives/dialogs";
4+
5+
6+
@Component({
7+
selector: 'modal-content',
8+
template: `
9+
<StackLayout margin="24" horizontalAlignment="center" verticalAlignment="center">
10+
<Label [text]="prompt"></Label>
11+
<StackLayout orientation="horizontal" marginTop="12">
12+
<Button text="ok" (tap)="close('OK')"></Button>
13+
<Button text="cancel" (tap)="close('Cancel')"></Button>
14+
</StackLayout>
15+
</StackLayout>
16+
`
17+
})
18+
class ModalContent {
19+
public prompt: string;
20+
constructor(private params: ModalDialogParams) {
21+
this.prompt = params.context.message;
22+
}
23+
24+
public close(res: string) {
25+
this.params.closeCallback(res);
26+
}
27+
}
28+
29+
const TEMPLATE = `
30+
<GridLayout rows="*, auto" modal-dialog-host>
31+
<Button text="show component" (tap)="showModal()"></Button>
32+
33+
<Label [text]="'RESULT: ' + result" row="1" margin="12"></Label>
34+
</GridLayout>
35+
`;
36+
37+
@Component({
38+
selector: 'modal-test',
39+
directives: [ModalDialogHost],
40+
providers: [ModalDialogService],
41+
template: TEMPLATE
42+
})
43+
export class ModalTest {
44+
public result: string = "---";
45+
46+
constructor(private modal: ModalDialogService) { }
47+
48+
public showModal() {
49+
const options: ModalDialogOptions = {
50+
context: { message: "Hello from dialog!" },
51+
fullscreen: true
52+
};
53+
54+
this.modal.showModal(ModalContent, options).then((res: string) => {
55+
this.result = res || "empty result";
56+
})
57+
}
58+
}
59+
60+
@Component({
61+
selector: 'modal-test-on-push',
62+
directives: [ModalDialogHost],
63+
providers: [ModalDialogService],
64+
changeDetection: ChangeDetectionStrategy.OnPush,
65+
template: TEMPLATE
66+
})
67+
export class ModalTestWithPushStrategy {
68+
public result: string = "---";
69+
70+
constructor(private modal: ModalDialogService) { }
71+
72+
public showModal() {
73+
const options: ModalDialogOptions = {
74+
context: { message: "Hello from dialog (onPush)!" },
75+
fullscreen: true
76+
};
77+
78+
this.modal.showModal(ModalContent, options).then((res: string) => {
79+
this.result = res || "empty result";
80+
})
81+
}
82+
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"nativescript": {
77
"id": "org.nativescript.testsappng",
88
"tns-ios": {
9-
"version": "2.0.0"
9+
"version": "2.0.1"
1010
},
1111
"tns-android": {
1212
"version": "2.1.0-2016-05-20-601"

0 commit comments

Comments
 (0)