Reputation: 1714
I created a Ionic, AngularJS, phonegap/cordova app.
In my index.html I have this snippet of pure javascript:
<script src="js/analytics/launchMyApp.js"></script>
<script type="text/javascript">
function handleOpenURL(url) {
// This function is triggered by the LaunchMyApp Plugin
setTimeout(function() {
alert("Hey the URL: " + url);
console.log(">>>>>>>>> Take me to the launchMyApp controller: " + url);
// Call controller function here
}, 3000);
}
</script>
The handleOpenURL function is triggered from the launchMyApp plugin:
nl.x-services.plugins.launchmyapp
Here is my controller:
communicatorApp.controller('LaunchMyAppCtrl', function($scope, $state) {
console.log(">>>>>>>> COOL!!!!");
$scope.launchMyAppHere = function(urlIn) {
console.log(">>>>>>>> GO MAN GO: " + urlIn);
};
});
My issue is I do not know how to call the launchMyAppHere function from the index.html javascript?
Upvotes: 2
Views: 5749
Reputation: 9811
Try this:
angular.element($("#elementID")).scope().launchMyAppHere();
where #elementID
is DOM ID of element where you attach you controller.
Upvotes: 2