我创建了一个Ionic,AngularJS,phonegap / cordova app。
在我的index.html中,我有一段纯粹的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>
handleOpenURL函数是从launchMyApp插件触发的:
nl.x-services.plugins.launchmyapp
这是我的控制器:
communicatorApp.controller('LaunchMyAppCtrl', function($scope, $state) {
console.log(">>>>>>>> COOL!!!!");
$scope.launchMyAppHere = function(urlIn) {
console.log(">>>>>>>> GO MAN GO: " + urlIn);
};
});
我的问题是我不知道如何从index.html javascript中调用launchMyAppHere函数?
答案 0 :(得分:2)
试试这个:
angular.element($("#elementID")).scope().launchMyAppHere();
其中#elementID
是您附加控制器的元素的DOM ID。