我有一个重定向到另一个页面的功能,我希望在重定向后重定向的页面也重新加载。
我想在重定向到登录页面后重新加载它。使用 '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']);
}
}
Run Code Online (Sandbox Code Playgroud) javascript typescript angular-routing angular angular-router