각도 4에서 현재 URL을 확인하고 "/ login"과 같은지 확인하려면 특정 양식을 제출해야합니다. 다음은 코드입니다.Typescript (각도 4의 경우)에서 문자열 동일성을 확인하는 올바른 방법은 무엇입니까
let responseString=this.router.url;
console.log(responseString);
if (responseString.match("/login")==null)
this.submitForm();
위의 코드는 모든 경우에 양식을 제출하지 않습니다. 내가 생각하는 if 조건에는 뭔가 잘못된 것이 있습니다. 실마리가 있습니까?
'if (responseString === "/ login")'시도해 보셨습니까? – lenny
일치는 동등 함을 테스트하지 않습니다. === 그렇습니다. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match –