How to use nativescript's WebView in angular2?

前端 未结 4 1289
抹茶落季
抹茶落季 2021-01-15 14:50

I\'m trying to insert a web-view on my page and listen the \'loadFinishedEvent\'... But for do this, i need to find the webview in my component

4条回答
  •  遥遥无期
    2021-01-15 15:14

    Good link for documentation for using WebView Nativescript/Android

    html:

     
    

    backend code:

    import {Component, OnInit} from "@angular/core";
    import {WebView, LoadEventData} from "ui/web-view";
    
    @Component({
        selector: 'basic-web-view-component',
        templateUrl: //see html above
    })
    
    export class BasicWebViewComponent implements OnInit {
    
        public url="https://www.google.com";
        @ViewChild("webview") webview: WebView;
    
        ngOnInit() {
    
            this.webview.on(WebView.loadFinishedEvent, function (args: LoadEventData) {
                 console.log("loadFinishedEvent called");
            });
        }
    }
    

    Note: that it seems that WebView needs to sized with width/height attributes are in a GridView, see the docs reference above. It won't dynamically grow based on content.

提交回复
热议问题