1

Can we check condition like below if not then what is other way??? I need to show console.log only below URl.

$location.$$absUrl.includes('localhost' || 'qa1' || 'cat1')

Below are my URL:

https://localhost:9005/

https://qa1.abc.com/

https://cat1.abc.com/

Rahul Pawar
  • 159
  • 1
  • 13

2 Answers2

1

Try:

var absUrl = $location.absUrl();
if(absUrl.match(/(localhost|qa1|cat1)/)){
   console.log(absUrl)
}
Shashank Vivek
  • 16,888
  • 8
  • 62
  • 104
1

to achieve what you expect, you should use regex pattern.

// If my domain contain localhost OR qua1 or cat1.
if (!$location.absUrl().match(/(localhost|qa1|cat1)/)) {
    // then override console.log to empty function.
    console.log = function(){ }; 

    //Is equal to do : window['console']['log'] = function(){ };
}

UPDATE

if you want to disable all kind of console output check this other topic

Yanis-git
  • 7,737
  • 3
  • 24
  • 41