I'm having a little problem that I do not know how to solve, I'm trying to run an example that is in ngcordova site but without success.
When I use the plugin $ cordovaInAppBrowser.open ({...
it usually works but to place the event listener
document.addEventListener (function () {... it does not open the link
in cordovaInAppBrowser.open $ ({...
I need to use the event listener to use the functions
necessary application, I can not understand what is
going on I am using the example without touching on
anything
Can someone help me ?
Here 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){
});
});
Only need to open an external page but document.addEventListener listener (function () {not let me open and I need him to be present as in the sample code to work correctly.
The only solution I found was this direct opening the window and making the necessary changes directly to the external page, thank the help of all.
Here's the code I used
var options = {
location: 'yes'
clearcache 'yes'
toolbar: 'no'
};
$ Scope.ircadastro = function () {
$ CordovaInAppBrowser.open ('url', '_blank', options)
}