首页 > 解决方案 > 角度:重定向后重新加载页面

问题描述

我有一个重定向到另一个页面的功能,我希望在重定向后重定向页面也重新加载。

我想在重定向到登录页面后重新加载它。使用 'window.location.reload()' 重新加载当前页面,该页面是主页但不是登录页面。如何重新加载特定页面?

主页组件.ts

import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { FormGroup, FormBuilder, FormControl, Validators, Form } from '@angular/forms';
import { LoginComponent } from '../authentification/login/login.component';



@Component({
  selector: 'app-home',
  templateUrl: './home.component.html',
  styleUrls: ['./home.component.scss']
})



export class HomeComponent implements OnInit {
  
  ngOnInit(): void {
   
  }

  constructor(private router: Router) { }


   redirection(){
    this.router.navigate(['/login']);
   }

  
}

标签: javascriptangulartypescriptangular-routingangular-router

解决方案


你为什么不使用

redirection(){
   window.location.href="yourpagedomain/login"
 } 

它将加载页面。


推荐阅读