问题描述
eSignAndRegistration: boolean;
registration: boolean;
esign: boolean;
css: boolean;
ngOnInit(): void {
if (this.activatedRoute.snapshot.queryParamMap.has('registration')) {
this.registration = true;
} else if (this.activatedRoute.snapshot.queryParamMap.has('esign®istration')) {
this.eSignAndRegistration = true;
} else if (this.activatedRoute.snapshot.queryParamMap.has('esign')) {
this.esign = true;
} else if (this.activatedRoute.snapshot.queryParamMap.has('css')) {
this.css = true;
}
}
为什么“&”符号会这样?我如何才能使用“esign®istration”使布尔值“eSignAndRegistration”为真。
解决方法
我在 if 语句中添加了多个条件并使其正常工作:
if (
this.activatedRoute.snapshot.queryParamMap.has('esign') &&
this.activatedRoute.snapshot.queryParamMap.has('registration')
) {
this.eSignAndRegistration = true;
} else if (this.activatedRoute.snapshot.queryParamMap.has('registration')) {
this.registration = true;
} else if (this.activatedRoute.snapshot.queryParamMap.has('esign')) {
this.esign = true;
} else if (this.activatedRoute.snapshot.queryParamMap.has('css')) {
this.css = true;
}