Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are plural expressions in Angular template syntax?

Webstorm offers syntax highlighting options for Angular Templates, and one of those options is called "plural expression".

And as you can see from the screenshot, it has a single set of curly braces, commas have a special meaning, and other weirdness I've seen nowhere else in Angular's template syntax.

What is this?

enter image description here

like image 508
Kevin Beal Avatar asked Mar 05 '26 14:03

Kevin Beal


1 Answers

The usage for plural is like this

{totalItemCount, plural, =0 {no files} =1 {1 file} other { {{totalItemCount | number}} files } selected

So based on totalItemCount if it's 0 then output no files, if 1 then output 1 file else number of selected items + selected

output will be like

no file selected
1 file selected
15 files selected

There is a tutorial here

Also there is an equivalent with NgPlural

like image 70
Reza Avatar answered Mar 08 '26 21:03

Reza



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!