Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/403.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript angular2 obj:布尔值不工作_Javascript_Angularjs_Angular - Fatal编程技术网

Javascript angular2 obj:布尔值不工作

Javascript angular2 obj:布尔值不工作,javascript,angularjs,angular,Javascript,Angularjs,Angular,由于某种原因,我的布尔值似乎没有设置为true,它在我以前的代码中起作用。两个代码基本相同,因此一旦满足if()语句,则setTimeout工作正常,则*ngIf应变为true 当前: isload:布尔值; 登录(用户){ var authenticatedUser=users.find(u=>u.username==user.username); var sessionKey=btoa(user.username); if(authenticatedUser&&authenticated

由于某种原因,我的
布尔值
似乎没有设置为
true
,它在我以前的代码中起作用。两个代码基本相同,因此一旦满足
if()
语句,则
setTimeout
工作正常,则
*ngIf
应变为true


当前:

isload:布尔值;
登录(用户){
var authenticatedUser=users.find(u=>u.username==user.username);
var sessionKey=btoa(user.username);
if(authenticatedUser&&authenticatedUser.password==user.password){
this.isLoading=true;
setItem('sessionKey',sessionKey);
设置超时(()=>{
这个.u路由器.导航(['/dashboard']);
}, 1000);
返回true;
}
返回false;
}
以前的:

isload:布尔值;
登录(){
var uname=this.data.username;
var pass=this.data.password;
//虚拟会话密钥
var sessionKey=(btoa(uname)+btoa(pass));
如果(uname==“user1”&&pass==“pass1”){
this.isLoading=true;
setItem('sessionKey',sessionKey);
设置超时(()=>{
这个.u路由器.导航(['/dashboard']);
}, 1000)
}...

JavaScript控制台中有错误吗?您是否调试代码以确保当前代码中实际调用了
this.isLoading=true;
?奇怪的是,它返回的是未识别的,并且没有控制台错误。您所说的“它返回的是未识别的”是什么意思?如何/何时调用
loginAction
方法?啊,它当前在服务中,我将它移动到按钮动作发生的组件。是的,它现在工作了,啊哈,感谢您指出调用它的位置。JavaScript控制台中有任何错误吗?您是否调试代码以确保
this.isLoading=true;
在您当前的代码中实际调用了吗?奇怪的是,它返回的是未识别的,并且没有控制台错误。您所说的“它返回的是未识别的”是什么意思?如何/何时调用
loginAction
方法?啊,它当前在服务中,我将它移动到按钮动作发生的组件。是的,它现在工作了,啊哈,感谢您指出它被调用的位置。