login.component.ts
976 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { Component, OnInit } from '@angular/core';
import { LoginService } from './login.service';
import { Router } from '@angular/router';
@Component({
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss'],
providers: [LoginService]
})
export class LoginComponent implements OnInit {
loginLoading: boolean = false;
usuario: object = {};
constructor(private loginService: LoginService, private router: Router) { }
ngOnInit() {
let glnPrevius = localStorage.getItem('gln')
if (glnPrevius) {
this.usuario['gln'] = glnPrevius;
}
}
ingresar() {
this.loginLoading = true;
this.loginService.getLogin(this.usuario).subscribe(login => {
if(login['data'] == 'ok') {
localStorage.setItem('gln', this.usuario['gln'])
this.router.navigateByUrl('/home');
} else {
alert('No se encontró la estación');
this.loginLoading = false;
}
});
}
}