问题标签 [angularjs-orderby]
For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.
javascript - 对angularjs中的复选框值进行排序
我想用 AngularJs 对表中的一列真/假复选框进行排序(即首先显示所有空复选框,反之亦然)。
复选框绑定到模型,并且相应地显示复选标记,但我无法对列进行排序。有可能以角度做到这一点吗?
angularjs - AngularJs排序顺序无法正常工作
请告诉我我的代码有什么问题。当您单击表格标题时,$scope.sort 得到了正确的值,但它没有按字母顺序对表格进行排序。
您可以在此处使用JSON文件查看 plunkr:http ://plnkr.co/edit/DYwbqDzBVTkQalhDtc6i?p=preview
在此处查看控制台日志http://embed.plnkr.co/DYwbqDzBVTkQalhDtc6i/
angularjs - Angularjs ng-repeat 与 orderby
我想使用 ng-repeat 以数组对象的 asc 顺序呈现数据。下面一个是数组对象。
angularjs - 在页面上多次使用 Angular 命名空间 orderBy 时未绑定
我在一个页面上有大约四个可以排序的主要 div(至少它们是通过 jQuery 进行的),我已经通过在 orderBy 条件中的管道将它们转换为 NG 排序并将其绑定到 ng-click。它适用于第一个组,但是当我尝试第二组时,它向我咆哮,因为 orderBy 的命名空间没有被绑定,所以我假设改变它的排序依据是不够的。
现在,我在 ng-repeat 中填充了一些日期:
当用户单击此处的链接时对其进行排序:
在我的控制器中,我在这里有一个简单的范围绑定:
所以这一直有效,直到我尝试再次执行此操作,我需要为页面上的四个单独的组至少执行四次。
因此,每个新的 ling-repeat 将是: blahConditions 中的条件 blipConditions 中的条件等...
所以我的问题是如何将每个 orderBy 绑定到它的特定组?
任何建议表示赞赏。
angularjs - 在 ng-repeat 上使用 orderBy 和多维数组
我有一个通过 websocket 进入的动态数据模型,如下所示:
我正在使用我的 ng-repeat 如下:
每当我需要访问结果数组中的一个数组时,我都会这样做:
我遇到的问题是 ngRepeat 上的 orderBy 过滤器似乎不允许我这样做:
也许这是对 Angular 如何工作的基本误解,但我不明白为什么这不起作用。是语法不正确,还是因为我的数据模型是动态的?我应该在某处设置 $scope.$apply 吗?
我尝试过使用引号,并且尝试在最初解析数据的函数中设置谓词,将谓词设置为 result.name 的每个实例,但这也不起作用。
很感谢任何形式的帮助。
angularjs - Set initial state of ng-show for orderBy in Angular
Trying to set the initial state of an arrow that I am showing for a list that is sortable. There are three columns and each one has a link bound to an ng-click
that when clicked will sort the list.
It's working as I need it to but the state of the up and down arrows do not show until clicked. And when I click one the other disappears. What I would like is for all the arrows to always show even before the user clicks and for each one to change direction on click of any of the three.
The basic link is this:
And right now I just have a basic setup in the scope:
angularjs - AngularJS:选项选择上的 OrderBy 过滤器
我正在制作一个小型应用程序,用于对用户拥有的点列表进行排序,类似于游戏排行榜。我已经在一组对象上设置了一个 ng-repeat,并在不同的选项上设置了一个 ng-show 以在列表中显示一个跨度。跨度显示不同的分数。
我在 ng-repeat 上添加了 orderBy 过滤器,因此列表从最大到最小过滤。For instance, when the option select of 'Threads Created' is chosen, then the scores for 'Post Read' and 'Posts Replied' are hidden and the list is sorted by the number of Threads Created (largest to smallest).
它适用于两个选项值,但不适用于第三个。知道为什么吗?
javascript - Angular 在 orderBy 之后获得中间索引
如您所知,在orderBy
table 失去其排序并且$index
值来自排序后的数组,而不是来自原始数组之后。因此,如果您将一个items
数组传递['orange', 'banana','potato','apple']
给您ng-repeat
的 ,在orderBy
UI 上的 an 之后,您将看到它们如下所示:
如果您现在想在之间多选项目apple($index = 0)
,orange($index = 2)
您可能会认为这会起作用:
这是错误的,它将打印:[orange, banana, potato]
; 不是[apple, banana, orange]
。
我正在寻找一种在 orderBy 之后获取显示数组的间隔索引的方法,有什么想法吗?
编辑:为了澄清,假设在 UI 上您已经排序items
,然后选择苹果,然后选择橙色:
我想要一种方法来知道items
这两个 selected 之间的中间值,这样我就可以在我们的例子中选择所有中间值banana
。
angularjs - AngularJS:orderBy - 字符串和数组不一样
我有一组用户:
当我使用orderBy:'name'
结果是:
- 安
- 安
- 巴
但是当我使用多个字段时orderBy:['name','age']
,结果是不同的:
- 安
- 巴
- 安
等待您的帮助!
angularjs - AngularJS orderBy 过滤器不适用于服务填充的数据
我是 AngularJS 的新手。我正在尝试过滤recipe
由recipeService
. 我的对象出现,但没有应用过滤器。
如果我将项目直接附加到my中$scope
调用的变量,而不是使用,则过滤器将起作用。recipes
controller.js
ng-repeat="recipe in recipes"
有什么建议吗?问候。
HTML
<li ng-repeat="recipe in recipeService.allRecipes | orderBy:'name':reverse">{{recipe.name}}</li>
我工厂的reciperService.service.js:
控制器声明中的controller.js: