1
1
import { Component , EventEmitter , OnInit , Output } from '@angular/core' ;
2
2
import { FormControl , FormGroup , Validators } from '@angular/forms' ;
3
+ import { AppConfig } from '../../../../app.config' ;
3
4
4
5
@Component ( {
5
6
selector : 'app-login-form' ,
@@ -9,19 +10,22 @@ import { FormControl, FormGroup, Validators } from '@angular/forms';
9
10
export class LoginFormComponent implements OnInit {
10
11
@Output ( ) sendLoginForm = new EventEmitter < void > ( ) ;
11
12
public form : FormGroup ;
12
- public flatlogicEmail = '[email protected] ' ;
13
- public flatlogicPassword = 'admin' ;
13
+ config : any ;
14
+
15
+ constructor ( appConfig : AppConfig ) {
16
+ this . config = appConfig . getConfig ( ) ;
17
+ }
14
18
15
19
public ngOnInit ( ) : void {
16
20
this . form = new FormGroup ( {
17
- email : new FormControl ( this . flatlogicEmail , [ Validators . required , Validators . email ] ) ,
18
- password : new FormControl ( this . flatlogicPassword , [ Validators . required ] )
21
+ email : new FormControl ( this . config . auth . email , [ Validators . required , Validators . email ] ) ,
22
+ password : new FormControl ( this . config . auth . password , [ Validators . required ] )
19
23
} ) ;
20
24
}
21
25
22
26
public login ( ) : void {
23
27
if ( this . form . valid ) {
24
- this . sendLoginForm . emit ( ) ;
28
+ this . sendLoginForm . emit ( this . form . value ) ;
25
29
}
26
30
}
27
31
}
0 commit comments