import { Component, OnInit, Inject, ViewChild } from "@angular/core"; import { CacheTokenService } from "../http-interceptors/cache-token.service"; //引入服务 import { HttpClient, HttpHeaders } from "@angular/common/http"; import { FormControl } from "@angular/forms"; import { MatDialog, MatDialogRef, MAT_DIALOG_DATA, } from "@angular/material/dialog"; import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar"; import { IsLoginService } from "../is-login.service"; import { ComponentServiceService } from "../component-service.service"; import { Router, ActivatedRoute } from "@angular/router"; @Component({ selector: "app-navigation", templateUrl: "./navigation.component.html", styleUrls: ["./navigation.component.scss"], }) export class NavigationComponent implements OnInit { constructor( private router: Router, private route: ActivatedRoute, public emitService: ComponentServiceService, public navmenus: CacheTokenService, private http: HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public islogin: IsLoginService ) {} roleType = sessionStorage.getItem("roleType"); ngOnInit() { if (this.router.url.indexOf("createexam-index") !== -1) { this.selectedNav = "创建考试"; } if (this.router.url.indexOf("mark-papers-index") !== -1) { this.selectedNav = "阅卷"; } if (this.router.url.indexOf("statistic") !== -1) { this.selectedNav = "统计分析"; if (this.router.url.indexOf("statistic-examination") !== -1) { this.selectedNav2 = "考试统计"; } else { this.selectedNav2 = "能力分析"; } } } selectedNav; selectedNav2; routerTo(name) { this.selectedNav = name; if (name === "统计分析") { this.selectedNav2 = "考试统计"; this.router.navigate([RouterUrl["考试统计"]]); //登陆成功跳转页面 } else { this.router.navigate([RouterUrl[name]]); //登陆成功跳转页面 } } routerTo2(name) { this.selectedNav2 = name; this.router.navigate([RouterUrl[name]]); //登陆成功跳转页面 } } enum RouterUrl { "创建考试" = "/home/createexam-index", "阅卷" = "/home/mark-papers-index", "考试统计" = "/home/statistic-examination", "能力分析" = "/home/statistic-capacity", }