I want to use the InAppBrowser defined in a controller, but I can’t access it in the $scope
. I get an error: TypeError: Object #<Scope> has no method 'open'
when calling inApp.open
.
console.log(inApp)
return ChildScope
.
dashboard.controller('DashboardCtrl', ['Restangular', '$scope', '$cordovaInAppBrowser', function (Restangular, $scope, $cordovaInAppBrowser) {
var inApp = $cordovaInAppBrowser.init({
location: 'no',
clearcache: 'yes'
});
inApp.$on('loadstop', function(event) {
var url = event.url;
console.log(url);
var filename = url.substring(url.lastIndexOf('/')+1);
console.log(filename);
if(filename == "mobile.login.html"){
inApp.close();
}
});
console.log(inApp);
$scope.googleLogin = function() {
console.log(inApp);
inApp
.open('http://http://192.168.0.27:3000/auth/google', '_blank')
.then(function(event) {
// success
})
.catch(function(event) {
// error
});
}
});