Angular 条件不工作时的角度HTTP POST方法

Angular 条件不工作时的角度HTTP POST方法,angular,if-statement,post,methods,conditional-statements,Angular,If Statement,Post,Methods,Conditional Statements,在angular 7中,我在使用Http POST时出错。但当我尝试在if条件中使用该错误值时,if条件不被执行,总是else部分被执行 与节点js成角度(平均值) console.log(this.errorParameter)=>true但也 如果情况不好,就不能进去。。仅false始终执行似乎您正在以字符串形式接收错误值,因此请检查如下条件 this.errorParametre === 'true' 似乎您正在以字符串形式接收错误值,所以请检查如下条件 this.errorParame

在angular 7中,我在使用Http POST时出错。但当我尝试在if条件中使用该错误值时,if条件不被执行,总是else部分被执行

与节点js成角度(平均值)

console.log(this.errorParameter)=>true
但也
如果情况不好,就不能进去。。仅
false
始终执行

似乎您正在以字符串形式接收错误值,因此请检查如下条件

this.errorParametre === 'true'

似乎您正在以字符串形式接收错误值,所以请检查如下条件

this.errorParametre === 'true'

请处理如下错误:-

this.http.post(`${this.uri}/compare`, {obj , err}).subscribe(
      response => {
          console.log('Successful');
      },
      err => {
          console.error("Error");
          this.errorParametre = true
      }
);

请处理如下错误:-

this.http.post(`${this.uri}/compare`, {obj , err}).subscribe(
      response => {
          console.log('Successful');
      },
      err => {
          console.error("Error");
          this.errorParametre = true
      }
);

检查
this.errorParameter==true
(双等于),您得到的返回可能是字符串是您的“err”值
true
是“true”
?检查
this.errorParameter==true
(双等于),您得到的返回可能是字符串是您的“err”值
true
是“true”
?是的,非常感谢。。我得到的错误值是字符串,但我试图将其与布尔值进行比较。。这就是原因。是的,非常感谢你。。我得到的错误值是字符串,但我试图将其与布尔值进行比较。。这就是原因。。