Angular6 implements the jump to the home page in the ts file

    In
  • angular6, what do you do if you want to jump to index.html, through code in the component"s ts file?
  • Let"s also talk about the most primitive requirements:

    if you use the modal form to display the login page in the home page, after successfully logging in, the modal form is set to invisible.
    then the home page is reflected. After clicking "Log out", you need to jump back to the main page and set the modal form
    to be visible, so there is the need to jump to the home page in the ts file
    .
Dec.13,2021

just skip routing what the home page route is.


  constructor(private router:Router) {

  }

   ...

   jumpToHome():void{
            this.router.navigateByUrl('/');
   }
Menu