类型错误: 无法读取未定义的属性“then”
2022-08-30 05:11:30
loginService.islogged()
上面的函数返回一个类似于“failed”的字符串。但是,当我尝试运行然后在其上运行时,它将返回错误
TypeError: Cannot read property 'then' of undefined
并且光标紧跟在 之后和之前指示。connected
.then
以下是完整的功能:
var connected=loginService.islogged();
alert(connected);
connected.then(function(msg){
alert("connected value is "+connected);
alert("msg.data value is "+msg.data);
if(!msg.data.account_session || loginService.islogged()=="failed")
$location.path('/login');
});
更新
这是函数islogged()
islogged:function(){
var cUid=sessionService.get('uid');
alert("in loginServce, cuid is "+cUid);
var $checkSessionServer=$http.post('data/check_session.php?cUid='+cUid);
$checkSessionServer.then(function(){
alert("session check returned!");
console.log("checkSessionServer is "+$checkSessionServer);
return $checkSessionServer;
});
}
我确信这将导致“失败”字符串。而已。$checkSessionServer