Rahul Matte
Rahul Matte

Reputation: 1181

Call Angular 5 function from Android WebView

I am trying to call Angular 5 function from my Abdroid WebView.

In Android

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT){
this.mWebView.evaluateJavascript("fooBar();", null);
} else {
this.mWebView.loadUrl("fooBar();");
}

In my Angular component I have added fooBar function

In Angular Component

fooBar=function(){
console.log("fooBar");
}

But above code throws

Error

VM772:1 Uncaught ReferenceError: fooBar is not defined at <anonymous>:1:1

Could anyone help me on How to call Typescript function from Android Webview

Upvotes: 1

Views: 2501

Answers (1)

Grenther
Grenther

Reputation: 476

See How do expose angular 2 methods publicly?

I don't know why you would do this, in your android webview. Maybe reevaluate that decision, tho I don't know the specifics. (would comment but can't)

Upvotes: 1

Related Questions