【问题标题】:What are plural expressions in Angular template syntax?Angular 模板语法中的复数表达式是什么?
【发布时间】:2019-08-18 13:09:48
【问题描述】:

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

从屏幕截图中可以看出,它有一组花括号、逗号有特殊含义,以及其他我在 Angular 模板语法中从未见过的奇怪之处。

这是什么?

【问题讨论】:

    标签: angular angular2-template


    【解决方案1】:

    复数的用法是这样的

    {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

    【讨论】:

      猜你喜欢
      • 2015-06-21
      • 2012-03-22
      • 2019-12-10
      • 1970-01-01
      • 2013-01-22
      • 1970-01-01
      • 2022-01-04
      • 2011-04-12
      • 1970-01-01
      相关资源
      最近更新 更多