login-dialog.component.ts
955 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, NgZone, OnInit} from '@angular/core';
import {MatDialog, MatDialogConfig} from "@angular/material";
import {LoginComponent} from "../login-component/login.component";
import {Router} from "@angular/router";
@Component({
selector: 'moya-login-dialog',
templateUrl: './login-dialog.component.html',
styleUrls: ['./login-dialog.component.css']
})
export class LoginDialogComponent implements OnInit {
constructor(private router: Router, private dialog: MatDialog) { }
ngOnInit() {
}
openLoginDialog(): void {
let conf = new MatDialogConfig();
conf.autoFocus = true;
/*conf.height = "800px";
conf.width = "500px";*/
let dialogRef = this.dialog.open(LoginComponent, conf);
dialogRef.componentInstance.loginEvent.subscribe((success) => {
if(success) {
dialogRef.close();
} else {
dialogRef.close();
this.router.navigateByUrl("/login");
}
});
}
}