Currently, I am working on an Angular application that is housed within an Android WebView. To facilitate communication with my Android application, I have made an object accessible at the window level:
window.MyAndroidApp
This object contains various methods such as:
window.MyAndroidApp.doStuff();
window.MyAndroidApp.doOtherStuff();
I find myself unsure of how to interact with this object through an Angular controller without directly referencing it. This way, I can easily mock it for unit testing purposes.
// How can I set androidFunctions as a reference to window.MyAndroidApp so that
// I can mock it during unit testing?
app.controller("MyCtrl", ["$scope", "androidFunctions", function($scope, androidFunctions) {
androidFunctions.doStuff();
androidFunctions.doOtherStuff();
}]);