当我使用 'esign&registration' 时,它使 'registration' 为真当我使用“esignandregistration”时,它会使“eSignAndRegistration”为真

问题描述

  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&registration')) {
      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&registration”使布尔值“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;
}

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...