I have this :
if (this.router.url === '/test/sort') {
this.active = 0;
}
Problem is that sometimes url will be test/sort?procesId=11
and than it will not enter in if statement. Any suggestion how can i do that?
Use indexOf() to Check if URL Contains a String When a URL contains a string, you can check for the string's existence using the indexOf method from String. prototype. indexOf() . Therefore, the argument of indexOf should be your search string.
Method String. includes(searchString: string, position?: number): boolean - Returns true if searchString appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.
The indexOf() method returns the position of the first occurrence of a value in a string. The indexOf() method returns -1 if the value is not found. The indexOf() method is case sensitive.
Find Your Router's IP Address Most routers use an address of 192.168. 1.1, but that's not always the case, so you may first want to confirm the address of your router. To find your router's IP address, type cmd in the Windows search bar open the Command Prompt. Type ipconfig and run the command.
If you want something basic that works:
if (this.router.url.indexOf('/test/sort') > -1) {
this.active = 0;
}
You can also use:
if (this.router.url.includes('/test/sort'))
{
this.active = 0;
}
Method String.includes(searchString: string, position?: number): boolean
- Returns true
if searchString
appears as a substring of the result of converting this object to a String, at one or more positions that are greater than or equal to position; otherwise, returns false.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With