加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

AngularJS中的理解表达是什么?

发布时间:2020-12-17 07:44:24 所属栏目:安全 来源:网络整理
导读:我头脑中有几个关于理解表达的问题: 它定义的数据结构是什么? 是否适应其他语言? 它在哪里用于AngularJS?该API是否仅存在于select元素? From the docs: ngOptions – comprehension_expression – in one of the following forms: for array data sour
我头脑中有几个关于理解表达的问题:

>它定义的数据结构是什么?
是否适应其他语言?
>它在哪里用于AngularJS?该API是否仅存在于select元素?

From the docs:

ngOptions – comprehension_expression – in one of the following forms:

for array data sources:

  • label for value in array
  • select as label for value in array
  • label group by group for value in array
  • select as label group by group for value in array track by trackexpr

for object data sources:

  • label for (key,value) in object
  • select as label for (key,value) in object
  • label group by group for (key,value) in object
  • select as label group by group for (key,value) in object
理解表达式只是一种以特殊方式格式化的字符串,可由select指令识别.

它没有什么魔力,只有几种格式,因为有很多方法来处理和表示你的收藏(你的模型的数据结构,项目/项目属性选择作为范围的模型,关于标签的一些其他选项,分组等) .当您考虑所有这些选项时,允许复杂表达式并不奇怪.

假设你有这样的代码:

<select
  ng-model="color"
  ng-options="c.name group by c.shade for c in colors"></select>

为了诠释理解表达式并使用属性,你可以这样写:

<select
  ng-model="color"
  ng-data-type="object"
  ng-data="colors"
  ng-select="c"
  ng-label="c.name"
  ng-group-by="c.shade"></select>

扩展API后,属性方法可能会变得丑陋.此外,使用理解表达式更容易使用过滤器.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读