1

Ionic2 project. I used InAppBrowser in typescript and webview is based on tomcat server. I want to call typescript funtion from external javascript function. How can i call that function? Below my code.

import { Component, ViewChild, ElementRef } from '@angular/core';
import { NavController, Content } from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import * as $ from 'jquery';

@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
@ViewChild(Content) content: Content;

constructor(public navCtrl: NavController, private iab: InAppBrowser, 
private elementRef : ElementRef) {

var ref = window.open(url, '_self', 'location=yes');

 }

}

function getGPS(e):string { //the function returns a string 

  return "client getGPS func" ;
}

I just want to call getGPS function in javascript function. This is my javascript code.

umn2={
    getGPS: function(){
        document.getElementById("resultArea").value = //that is client part
    }
 };

Please tell me the solutions. Thank you.

1

1 Answer 1

0

The TypeScript has to be compiled first to Javascript. So the first step is to verify that.

Second this is that you have 2 different implementation of getGPS functions. One is defined on the umn2 object and the other is in the Typescript code. I think it should be exported from the typescript module, to be importable/usable from outside.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.