I am facing an issue with my HTML that uses an AngularJS directive. This HTML file is being used in an Android WebView, and I want to be able to call an Android method from this directive (Learn how to call Android method from JS here).
Below is the code for my directive:
return {
restrict: 'A',
link: function (scope, element, attrs) {
scope.$watch('controller.isReady', function (value) {
if (value === true) {
try {
Android.isReady();
} catch (e) {}
}
});
}
}
Since I am using Typescript, I am encountering an error stating that Android
is undefined. Even with pure AngularJS, the Android
object would remain undefined.
Is there a way to resolve this issue so that I can successfully call an Android method from AngularJS?