File tree 2 files changed +21
-8
lines changed
2 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 1
- import { EventData } from "data/observable" ;
1
+ import { EventData , Observable } from "data/observable" ;
2
2
import { Page } from "ui/page" ;
3
3
import { HelloWorldModel } from "./main-view-model" ;
4
- import { openUrl } from "utils/utils"
4
+ import { openUrl } from "utils/utils" ;
5
5
// Event handler for Page "navigatingTo" event attached in main-page.xml
6
6
export function navigatingTo ( args : EventData ) {
7
7
// Get the event sender
8
8
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 ;
9
16
}
10
17
11
18
export function onTap ( args :EventData ) {
12
19
console . log ( args . object . get ( "id" ) ) ;
13
20
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" ) ) ;
14
26
}
Original file line number Diff line number Diff line change 1
1
<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 ="  " 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 ="  " 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 >
8
9
</Page >
You can’t perform that action at this time.
0 commit comments