角度导航6

问题描述 投票:-1回答:1

如何根据某些函数的结果重定向到Angular 6中的其他组件?

Login(){

    console.log(this.LoginModel);
     this.userService.LoginUser(this.LoginModel).subscribe(
       result =>{
         if(result == null)
            console.log("Loged in successfully"); 
            /// here i want to go to dashboard component (router with path dashboard)               
       },
       error =>{
         console.log("Login - error");
       }

     );
  }
angular routing communication
1个回答
2
投票

将路由器服务注入您的构造函数。

import {Router} from "@angular/router";

constructor(
    private _router: Router
) {

}

goSomewhere() {
    this._router.navigate(['url']);
}
© www.soinside.com 2019 - 2024. All rights reserved.