Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the correct way to check for String equality in Typescript (for Angular 4)

In Angular 4, I want to check for the current url and if it is equal to "/login" I need to submit a specific form. Here is the code:

 let responseString=this.router.url;
 console.log(responseString);
 if (responseString.match("/login")==null)
   this.submitForm();

The above code does not submit the form in all cases. There is something wrong with the if condition I guess. Any clues?

like image 822
Donia Zaela Avatar asked Dec 04 '22 21:12

Donia Zaela


1 Answers

For simple string-to-string equality, you can use the === operator.

like image 169
Wrokar Avatar answered Dec 29 '22 09:12

Wrokar