Angular模板语法中的复数表达式是什么?

问题描述 投票:-1回答:1

Webstorm为Angular模板提供语法突出显示选项,其中一个选项称为“复数表达式”。

正如您从屏幕截图中看到的那样,它有一组花括号,逗号具有特殊含义,以及我在Angular的模板语法中看不到的其他奇怪之处。

这是什么?

enter image description here

angular angular2-template
1个回答
0
投票

复数的用法是这样的

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

所以基于totalItemCount,如果它是0然后输出no files,如果1然后输出1 file其他数量的选定项目+ selected

输出就像

no file selected
1 file selected
15 files selected

有一个教程here

还有一个与NgPlural相当的东西

© www.soinside.com 2019 - 2024. All rights reserved.