Steve
Steve

Reputation: 14912

Angular JS apply uppercase filter to boolean value?

I have an angular 1.4.12 binding:

{{ mob.mobDataSettings[7].value | uppercase }}

where the first part is a boolean from a json file which is of course either true or false.

however, in the rendered HTML it is not being uppercased (i.e. TRUE), it's printing as true.

Am I missing something obvious?

Upvotes: 3

Views: 1548

Answers (3)

dfsq
dfsq

Reputation: 193261

Another way to cast to string before filter:

{{ '' + mob.mobDataSettings[7].value | uppercase }}

Upvotes: 3

ValLeNain
ValLeNain

Reputation: 2304

If it's a boolean, even if it could work, it's bad practise to try to apply a filter made for strings.
I suggest you go with {{ mob.mobDataSettings[7].value ? "TRUE" : "FALSE" }}

Upvotes: 4

Maccurt
Maccurt

Reputation: 13817

{{ mob.mobDataSettings[7].value.toString() | uppercase }}

or could you just do

{{ mob.mobDataSettings[7].value.toString().toUpper() }}

Upvotes: 0

Related Questions