Skip to content

Commit 02c7137

Browse files
author
Nikolay Tsonev
committed
add web view
1 parent cd4fad9 commit 02c7137

File tree

2 files changed

+21
-8
lines changed

2 files changed

+21
-8
lines changed

Diff for: app/main-page.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,26 @@
1-
import { EventData } from "data/observable";
1+
import { EventData, Observable } from "data/observable";
22
import { Page } from "ui/page";
33
import { HelloWorldModel } from "./main-view-model";
4-
import {openUrl} from "utils/utils"
4+
import {openUrl} from "utils/utils";
55
// Event handler for Page "navigatingTo" event attached in main-page.xml
66
export function navigatingTo(args: EventData) {
77
// Get the event sender
88
var page = <Page>args.object;
9+
10+
let myobservable = new Observable();
11+
12+
myobservable.set("webviewid", "https://www.google.com");
13+
myobservable.set("webviewprop", "<span><font color='#ff0000'>Sample html code</font></span>");
14+
15+
page.bindingContext = myobservable;
916
}
1017

1118
export function onTap(args:EventData){
1219
console.log(args.object.get("id"));
1320
openUrl(args.object.get("id"));
21+
}
22+
23+
export function onWebViewTap(args:EventData){
24+
console.log(args.object.get("id"));
25+
openUrl(args.object.get("id"));
1426
}

Diff for: app/main-page.xml

+7-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo">
2-
<StackLayout>
3-
<Label text="Tap the button" class="title"/>
4-
<Button class="icon" text="&#xe986;" id="https://www.google.com" tap="onTap" />
5-
<Label text="{{ message }}" class="message" textWrap="true"/>
6-
<HtmlView html="https://google.com" />
7-
</StackLayout>
2+
<GridLayout rows="70 70 100 40" columns="* 70 *">
3+
<Label row="0" col="0" colSpan="3" text="Tap the button" class="title"/>
4+
<Button row="1" col="1" class="icon" text="&#xe986;" id="https://www.google.com" tap="onTap" />
5+
<WebView row="2" col="0" colSpan="3" width="100px" isUserInteractionEnabled="true" id="{{webviewid}}" tap="onWebViewTap" src="{{webviewprop}}" />
6+
7+
<HtmlView row="3" col="0" colSpan="3" html="https://google.com" />
8+
</GridLayout>
89
</Page>

0 commit comments

Comments
 (0)