C
C
Coder3212016-10-18 16:53:49
JavaScript
Coder321, 2016-10-18 16:53:49

How do you do authorization in Angular 2?

I have a canActivate method that requests the user from the server. at the moment everything works, but there is one not very pleasant moment, while the application is loading, the base preloader is spinning, then a blank screen while waiting for the server response. How to make the preloader spin until the server response arrives?

<body>
  <app-root>Loading...</app-root>
</body>

I need Loading... to glow before the response from the server comes.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
Skrolea, 2016-10-18
@Skrolea

export class Login{
     
      result:Array<Object>; 
      constructor(http: Http,private dd:dataService) { 
        
      this.dd.showLoader();
        
       this.dd.fetchData().subscribe((result) =>{ 
                    this.result =result
                    },
                    (err)=>console.log(err),
                    ()=>{console.log("Done")
                       this.dd.hideLoader();
                    }); 
                      
                      
       }
  }

So? Run the preloader, and hide it in the response from the service upon receipt

_
_ _, 2016-10-18
@AMar4enko

Do a server-side prerender with angular-universal

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question