Currently facing an issue that I'm struggling to resolve, attempting to execute a code snippet from the ngcordova website without success.
While using the plugin $cordovaInAppBrowser.open ({...
it generally functions well until the inclusion of the event listener
document.addEventListener (function () {... preventing the link from opening
in cordovaInAppBrowser.open $ ({...
I must have the event listener in place to utilize the necessary application functions, but I cannot comprehend what is occurring. I am simply utilizing the provided example as is.
Could someone provide assistance?
Provided below is the sample code:
module.controller('ThisCtrl', function($cordovaInAppBrowser) {
var options = {
location: 'yes',
clearcache: 'yes',
toolbar: 'no'
};
document.addEventListener(function () {
$cordovaInAppBrowser.open('http://ngcordova.com', '_blank', options)
.then(function(event) {
// success
})
.catch(function(event) {
// error
});
$cordovaInAppBrowser.close();
}, false);
$rootScope.$on('$cordovaInAppBrowser:loadstart', function(e, event){
});
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
// insert CSS via code / file
$cordovaInAppBrowser.insertCSS({
code: 'body {background-color:blue;}'
});
// insert Javascript via code / file
$cordovaInAppBrowser.executeScript({
file: 'script.js'
});
});
$rootScope.$on('$cordovaInAppBrowser:loaderror', function(e, event){
});
$rootScope.$on('$cordovaInAppBrowser:exit', function(e, event){
});
});
The primary goal is to access an external page, however, the document.addEventListener listener (function () {... prevents me from achieving this. It is essential for this listener to be present as shown in the sample code for the functionality to perform correctly.