[英]Cordova Inapp browser throws error
I get the followin error when I ue Cordova Inappbrowser ( http://ngcordova.com/docs/plugins/inAppBrowser/ ) 当我使用Cordova Inappbrowser时,我得到了跟随错误( http://ngcordova.com/docs/plugins/inAppBrowser/ )
TypeError: Cannot read property 'open' of undefined
$cordovaInAppBrowser.open(urlToGo, '_self', options) .then(function(event) { // success console.log("Success..."); }) .catch(function(event) { // error console.log("Error..."); }); $cordovaInAppBrowser.close();
Try and wrap your code in a device ready first; 首先尝试将代码包装在设备中;
document.addEventListener("deviceready", function () {
$cordovaInAppBrowser.open(urlToGo, '_self', options)
.then(function(event) {
// success
console.log("Success...");
})
.catch(function(event) {
// error
console.log("Error...");
});
$cordovaInAppBrowser.close();
}, false);
If that doesnt work try the official cordova-plugin-inappbrowser . 如果这不起作用尝试官方cordova-plugin-inappbrowser 。 I sometimes find that ng plugins dont always play nice.
我有时会发现ng插件并不总是很好玩。
Their example to trigger the browser. 他们的例子来触发浏览器。
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
window.open = cordova.InAppBrowser.open;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.