Javascript 我偶尔不在heroku工作

Javascript 我偶尔不在heroku工作,javascript,angular,heroku,angular-ui-router,Javascript,Angular,Heroku,Angular Ui Router,我有一个角度的方法: loginUser(email: string, password: string): void { if (email && password) { this.hasLoginMessage = true; this.loginMessage = "Login in progress"; this.api.login(email, password).then((result) => { if (result

我有一个角度的方法:

loginUser(email: string, password: string): void {
if (email && password) {
  this.hasLoginMessage = true;
  this.loginMessage = "Login in progress";

  this.api.login(email, password).then((result) => {
    if (result.status && result.status != 200) {
      this.loginMessage = "Login failed!";
      //Wrong password
    }
    else {
      this.api.setLoggedIn(result.token);
      this.router.navigate(['/dashboard']);

      try {
        var elementList = this.document.querySelectorAll('.modal-backdrop');
        for (let i = 0; i < elementList.length; i++) {
          elementList[i].removeAttribute('class');
        }
      }
      catch {}
      
      try {
        var elementList = this.document.querySelectorAll('.modal-open');
        for (let i = 0; i < elementList.length; i++) {
          elementList[i].removeAttribute('class');
          elementList[i].removeAttribute('style');
        }
      }
      catch {}
    }
  }).catch((error) => {
    this.api.userLoggedIn = null;
    this.loginMessage = "Login failed!";
    console.log(error);
  })
}
else {
  //Fields incorrect
}
登录用户(电子邮件:字符串,密码:字符串):无效{
如果(电子邮件和密码){
this.hasLoginMessage=true;
this.loginMessage=“正在登录”;
这个.api.login(电子邮件,密码)。然后((结果)=>{
if(result.status&&result.status!=200){
this.loginMessage=“登录失败!”;
//密码错误
}
否则{
this.api.setLoggedIn(result.token);
this.router.navigate(['/dashboard']);
试一试{
var elementList=this.document.querySelectorAll('.modal background');
for(设i=0;i{
this.api.userLoggedIn=null;
this.loginMessage=“登录失败!”;
console.log(错误);
})
}
否则{
//字段不正确
}
}

此.api.setLoggedIn(result.token)设置本地存储参数以记住用户已登录。当我尝试登录时,偶尔会设置本地存储参数(表示登录成功),但站点不会重定向到/dashboard。这个.router.navigate(['/dashboard'])后面的代码;仍在顺利执行。这个问题只出现在heroku中。你知道为什么吗