导航屏幕模糊/禁用后

时间:2018-06-12 10:23:34

标签: angular

**角度页面模糊/焦点问题**

我,正在处理角度和i的项目,我有一个错误,当我尝试导航到其他页面成功登录后,该页面就像模糊或没有聚焦,我必须刷新该页面使用它我以前没有遇到过这样的问题,我只是在导航到其他页面后关闭弹出窗口。代码在任何身体帮助下面给出。

 That is my code of my logincomponent.ts.



  import { Component, OnInit } from '@angular/core';
        import { NgForm } from '@angular/forms';
        import { error } from 'util';
        import { Router } from '@angular/router';
        import { TokenService } from '../Services/token.service';
        import {HttpClient} from '@angular/common/http';
        import { AuthService } from '../Services/auth.service';
        import { DISABLED } from '@angular/forms/src/model';



        @Component({
          selector: 'app-login',
          templateUrl: './login.component.html',
          styleUrls: ['./login.component.css']
        })
        export class LoginComponent implements OnInit {

          public form={
            email:null,
            password:null,
          } 
          public error=null;
          showspinner:boolean=false;
          private popup:boolean=false;

          constructor(
                      private router: Router,
                      private token:TokenService,
                      private http : HttpClient,
                      private authService:AuthService,
                    ) {

           }
          ngOnInit() {
            this.resetForm();
          }

          resetForm(form? : NgForm)
          {
            if(form!=null)
                form.reset();
                  this.form={
                    email:null,
                  password:null,
              } 
          }

          private onLogin(form:NgForm){
            this.authService.login(this.form).subscribe((
              this.showspinner=true,
              data=>this.handleResponse(data)
            ));
          }

          handleResponse(data)
          {
             localStorage.setItem('token',data.data.api_key);
             if(localStorage.getItem('token')===data.data.api_key && data.data.api_key !==null)
             {
               this.router.navigate(['dashboard']);
               this.popup=false;
               this.form;
               this.resetForm();
             }
             else
             {
               this.resetForm();
              localStorage.removeItem('token');
              this.showspinner=false;
              this.error="User name or Passwrod is not correct";

             }

          }
        }



          [1]: https://i.stack.imgur.com/MGODo.png

0 个答案:

没有答案