Commit da0ae85b authored by Ratnadeep Rajendra Kharade's avatar Ratnadeep Rajendra Kharade
Browse files

added loading page on login api call

parent 221d2907
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router, LoadChildrenCallback } from '@angular/router';
import { Observable } from 'rxjs'; import { Observable } from 'rxjs';
import { HttpClient } from '@angular/common/http'; import { HttpClient } from '@angular/common/http';
import { RestService } from '../../rest.service'; import { RestService } from '../../rest.service';
import { UserService } from 'src/app/services/user.service'; import { UserService } from 'src/app/services/user.service';
import { LocationService } from 'src/app/services/location.service';
import { LoadingService } from 'src/app/services/loading.service';
@Component({ @Component({
selector: 'app-login', selector: 'app-login',
...@@ -15,12 +17,15 @@ import { UserService } from 'src/app/services/user.service'; ...@@ -15,12 +17,15 @@ import { UserService } from 'src/app/services/user.service';
export class LoginPage implements OnInit { export class LoginPage implements OnInit {
username = ""; username = "";
password = ""; password = "";
//username = "";
//password = "";
correctCredentials = false; correctCredentials = false;
loginApi: Observable<any>; loginApi: Observable<any>;
constructor(private router: Router, public httpClient: HttpClient, public restService: RestService,public userService: UserService) { constructor(private router: Router,
public httpClient: HttpClient,
public restService: RestService,
public userService: UserService,
public locationService: LocationService,
public loadingService: LoadingService) {
} }
...@@ -37,6 +42,7 @@ export class LoginPage implements OnInit { ...@@ -37,6 +42,7 @@ export class LoginPage implements OnInit {
"email": this.username, "email": this.username,
"password": this.password "password": this.password
}); });
this.loadingService.showLoader();
this.loginApi this.loginApi
.subscribe((data) => { .subscribe((data) => {
//console.log('my data: ', data); //console.log('my data: ', data);
...@@ -44,9 +50,11 @@ export class LoginPage implements OnInit { ...@@ -44,9 +50,11 @@ export class LoginPage implements OnInit {
this.restService.isLoginPage = false; this.restService.isLoginPage = false;
this.userService.setUsername(this.username); this.userService.setUsername(this.username);
this.router.navigateByUrl('/home'); this.router.navigateByUrl('/home');
this.loadingService.hideLoader();
}, (error) => { }, (error) => {
console.log(JSON.stringify(error)); console.log(JSON.stringify(error));
this.correctCredentials = true; this.correctCredentials = true;
this.loadingService.hideLoader();
}); });
} }
register() { register() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment