gpt4 book ai didi

angularjs - ng-repeat with a orderBy 在 v1.3.0-beta.13 之后对我不起作用

转载 作者:行者123 更新时间:2023-12-04 06:18:26 25 4
gpt4 key购买 nike

在此配置中使用时,有没有人注意到 ng-repeat 的问题:

<div ng-repeat="row in home.grid.view = (home.grid.data | orderBy:ctrl.contentOrderBy[ctrl.configService.admin.contentOrderBy].key:ctrl.configService.admin.contentSortDirection)">

这是我的 contentOrderBy 对象:
[{"id":0,"name":"CId","key":"contentId"},
{"id":1,"name":"Modified By","key":"modifiedBy"},
{"id":2,"name":"Modified Date","key":"modified"},
{"id":3,"name":"Status","key":"contentStatusId"},
{"id":4,"name":"Status > Type","key":["contentStatusId","contentTypeId"]}]

ctrl.configService.admin.contentSortDirection 有两个值:0 或 1

我的问题是当我尝试更改为 configService.admin.contentSortDirection 时:
  • @license AngularJS v1.3.0-beta.8 - 有效
  • AngularJS v1.3.0-beta.12 - 有效
  • AngularJS v1.3.0-beta.13 - 有效
  • AngularJS v1.3.0-beta.14 - 不改变方向
  • @license AngularJS v1.3.0-rc.5 - 不改变方向
  • @license AngularJS v1.3.0 - 不改变方向

  • 我检查了最新的文档,除非我弄错了,否则我找不到任何关于如何执行我认为曾经出现在以前的文档中的 orderBy 的信息。

    如果其他人知道这样做的工作方式,我将不胜感激。我也想知道为什么 ng-repeat 文档似乎有点缺乏。

    最佳答案

    更改行:

    <div ng-repeat="row in home.grid.view = (home.grid.data | orderBy:ctrl.contentOrderBy[ctrl.configService.admin.contentOrderBy].key:ctrl.configService.admin.contentSortDirection)">

    到:
    <div ng-repeat="row in home.grid.view = (home.grid.data | orderBy:ctrl.contentOrderBy[ctrl.configService.admin.contentOrderBy].key:ctrl.configService.admin.contentSortDirection == 1)">

    Harish 是在正确的轨道上,但他设置反向参数的方式完全错误:
    reverse=order.dir === 1

    没有要求放置“反向=”。

    您的问题是由 Beta 14 版本中的此更改引起的:
    fix(core): drop the toBoolean function
    So far Angular have used the toBoolean function to decide if the parsed value
    is truthy. The function made more values falsy than regular JavaScript would,
    e.g. strings 'f' and 'no' were both treated as falsy. This creates suble bugs
    when backend sends a non-empty string with one of these values and something
    suddenly hides in the application

    Thanks to lgalfaso for test ideas.

    BREAKING CHANGE: values 'f', '0', 'false', 'no', 'n', '[]' are no longer
    treated as falsy. Only JavaScript falsy values are now treated as falsy by the
    expression parser; there are six of them: false, null, undefined, NaN, 0 and "".

    Closes #3969
    Closes #4277
    Closes #7960

    关于angularjs - ng-repeat with a orderBy 在 v1.3.0-beta.13 之后对我不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26687575/

    25 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com