1
Ionic2プロジェクト。私はtypescriptでInAppBrowserを使用し、webviewはtomcatサーバーに基づいています。私は外部JavaScript関数からtypescript関数を呼び出す必要があります。どのように私はその機能を呼び出すことができますか? 私のコードの下に。外部JavaScript関数からtypescript関数を呼び出す方法
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" ;
}
私はちょうどjavascript関数でgetGPS関数を呼び出したいと思います。 これは私のJavaScriptコードです。
umn2={
getGPS: function(){
document.getElementById("resultArea").value = //that is client part
}
};
解決策を教えてください。ありがとうございました。
[JavaScriptから適切にタイプスクリプトコードを呼び出す](https://stackoverflow.com/questions/26427722/calling-properly-typescript-code-from-javascript)の可能な複製 –