【发布时间】:2020-02-16 17:59:21
【问题描述】:
我正在尝试从登录页面重定向页面。我有一个标志用于检查购物车是否为空。我可以将该标志设置为真或假。我想在登录后重定向页面取决于标志和是否登录。我尝试过但没有工作。请帮助任何人找到解决方案。
login.commponent.ts:
onSubmit() {
this.submitted = true;
if (this.loginForm.invalid) {
return;
}
this.loading = true;
this.authenticationService.login(this.f.username.value, this.f.password.value)
.pipe(first())
.subscribe(
data => {
//if cart is not empty
// if(this.flag==true){
// this.router.navigate(['./billing']);
// }
//if cart is empty
//else{
// this.router.navigate(['./cartempty']);
// }
//this.router.navigate([this.returnUrl]);
},
error => {
this.alertService.error(error);
this.loading = false;
});
}
order.component.ts:
goTOloginbilling(){
//if Not logged
// if(????){
// this.router.navigate(['./login']);
// }
//if cart is not empty
// else if(this.flag==true){
// this.router.navigate(['./billing']);
// }
//if cart is empty
//else if(this.flag==false){
// this.router.navigate(['./cartempty']);
// }
}
【问题讨论】:
-
用户名密码?
-
@brk: 你可以创建它..注册选项在那里
标签: javascript typescript angular7 angular8