0

I’m trying to replace the location strategy by condition prod/dev

console.log(IonicENV.mode) <= this loges true

Then

 { provide: LocationStrategy, useClass: (IonicENV.mode == "prod") ? PathLocationStrateg HashLocationStrategy }

Although IonicEnv.mode returns prod, so the condition is true. but it always goes into using HashlocationStrategy. There is no logical explanation at all…

if I do

{ provide: LocationStrategy, useClass: (console.log(IonicENV.mode == "prod")) ? PathLocationStrategy : HashLocationStrategy }

Then everything works correctly on the server. it meets the true condition and goes into using pathLocationStrategy… Any explanations…anyone??

R. Richards
  • 24,603
  • 10
  • 64
  • 64
Giriboy
  • 21
  • 2

1 Answers1

0

console.log() always return undefined and !!undefined is false. So

(console.log(IonicENV.mode == "prod")) ? PathLocationStrategy : HashLocationStratege

is the same as

(false) ? PathLocationStrategy : HashLocationStratege // because of braces

and is the same as HashLocationStratege

Przemyslaw Jan Beigert
  • 2,351
  • 3
  • 14
  • 19
  • but it did use PAthlocationStrategy when I wrap it using console log, so it was true – Giriboy Feb 07 '19 at 23:25
  • but `{ useClass: (console.log("prod" == "prod")) ? 0 : 1 }` == `{ useClass: 1 }` also `{ useClass: (console.log("notProd" == "prod")) ? 0 : 1 }` == `{ useClass: 1 }` so in second case it must be `HashLocationStrategy` – Przemyslaw Jan Beigert Feb 08 '19 at 06:58