[英]$timeout() not calling inappbrowser [Ionic]
I am using an initial screen(initial.html) and i want it to act as a splashscreen and then call the inappbrowser. 我正在使用初始屏幕(initial.html),我希望它充当启动屏幕,然后调用inappbrowser。
But inappbrowser is not opening. 但是inappbrowser没有打开。 If i place it directly it works.
如果我直接将其放置。 No error is also coming.
没有错误也来了。 The required functionality is to have a splash screen view getting redirected to inappbrowser, user will log in and upon successful login will be redirected to the view.( Individual parts are working, but when i put it inside a TimeOut function it is not working ).
所需的功能是使启动画面视图重定向到inappbrowser中,用户将登录,并且成功登录后将重定向到该视图。(各个部分都在工作,但是当我将其放入TimeOut函数中时,它就无法工作) 。
Is there any better way to achieve this functionality. 有没有更好的方法来实现此功能。
controller.js controller.js
.controller('LoginCtrl', function($scope,$timeout,$rootScope,LoginService, $ionicPopup, $state,$location,$ionicPopup) {
$timeout(function(){
LoginService.loginUser().success(function(data) {
console.log(data);
$location.path('app/playlists');
}).error(function(data) {
var alertPopup = $ionicPopup.alert({
title: 'Login failed!',
template: 'Please check your credentials!'
});
});
}, 3000);
})
services.js services.js
angular.module('starter.services', [])
.service('LoginService', function($q,$rootScope,$cordovaInAppBrowser,$http,$state,jwtHelper,$location) {
return {
loginUser: function() {
var deferred = $q.defer();
var promise = deferred.promise;
console.log("Hi Service"); // IT IS REACHING HERE THEN STUCK
$cordovaInAppBrowser.open(URL, '_self',options).then(function(event){
console.log(event);
// success
})
.catch(function(event) {
console.log(event);
// error
});
$rootScope.$on('$cordovaInAppBrowser:loadstop', function(e, event){
if(userValid){
deferred.resolve(username); }
else{
deferred.reject('Auth Failed');
}
});
//promise created outside
promise.success = function(fn) {
promise.then(fn);
return promise;
}
promise.error = function(fn) {
promise.then(null, fn);
return promise;
}
return promise;
}
});
I removed and reinstalled the inappbrowser plugin and it worked correctly. 我删除并重新安装了inappbrowser插件,它可以正常工作。 I apologize for the confusion
对此我深表歉意
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.