[英]Conditionally change angular location strategy
I'm trying to replace the location strategy by condition prod/dev 我正在尝试用条件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. 尽管IonicEnv.mode返回prod,所以条件为true。 but it always goes into using HashlocationStrategy.
但它总是要使用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??
它符合真实条件,并开始使用pathLocationStrategy ...任何解释...有人吗?
console.log()
always return undefined
and !!undefined
is false
. console.log()
总是返回undefined
, !!undefined
为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
并且与
HashLocationStratege
相同
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.