Mu'men Tayyem
Mu'men Tayyem

Reputation: 163

Comparing boolean in html not working as expected

I have a flag called isReadOnly which I read value from query string parameter using the below statement.

this.isReadOnly = this.activatedRoute.snapshot.params['isReadOnly'];

I'm getting the value correctly but the issue is that comparing this flag in html or the negation of it is not working as expected.

for example look at the below code: isReadOnly:{{isReadOnly}} -->if true <br> isReadOnly==false:{{isReadOnly==false}} --> returns false which is correct

but isReadOnly:{{isReadOnly}} --> if false <br> isReadOnly==false:{{isReadOnly==false}} --> returns false! its false == false, it should return true!

this is happening in IONIC 4 Page

any help please?

thanks in advance.

Upvotes: 0

Views: 30

Answers (1)

Ehsan K. harchegani
Ehsan K. harchegani

Reputation: 3128

Maybe if you use it like this it works

isReadOnly==true? true :false

that mean if isReadOnly is true return true and if not return false.

Upvotes: 1

Related Questions