问题标签 [angularjs-filter]
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 ng-repeat orderBy 订单编号不正确
我在使用ng-repeat
orderBy
文本中有数字时遇到问题。
样本数据:
当使用ng-repeat
with 时,请orderBy: 'booth'
列出:p1、p10、p11、p13、p2 等
我知道这是预期的行为,但有谁知道我怎样才能让它按照我期望的顺序列出展位?
这将是:p1、p2、p3、p4/5 等
我还尝试查看问题是否是因为数字不是整数但返回了相同的问题。
预先感谢您的任何帮助。
javascript - AngularJS - 过滤 Javascript 地图
我一直在尝试实现过滤 JS 映射对象(由 id 索引的数组),而不是 angularJS 中通常的 js 数组。
为了说明,下面是AngularJS 文档中提供的过滤示例的轻微修改。
http://plnkr.co/edit/bNzePyuAAmP6Nl6hj5bI?p=preview
我已将输入数组(朋友)转换为 JSON 对象,每个初始数组元素都映射为单独的键控元素。这种修改可以理解如下:
初始(如 AngularJS 文档中所示):
修改的:
有人可以提供一种方法来过滤这样的输入作为 ng-repeat 指令过滤器表达式的一部分。我知道“朋友”不再是一个数组而是一个对象,但是由于 ng-repeat 指令正在处理这个对象,也许还有一种过滤它的方法?
谢谢。
angularjs - AngularJs:使用过滤器选项搜索无法正常工作
我对 angularjs 中的过滤文本有疑问。
我有一个名为“用户”的联系人 JSON 数组
用于搜索过滤器的 HTML
在 HTML 中,我只打印contactName,因为我只想使用上面的文本框过滤“姓名”,而不是使用contactEmail 或contactMobile ...但过滤选项是使用contactEmail 和contactMobile 过滤数据,因为JSON 具有这些对象...。但如果不从 JSON 数组中删除 json 对象(contactEmail 和contactMobile),我如何仅使用contactName 过滤数据。
angularjs - AngularJS Filter being called related to number of scopes on the page?
I have a page that has a number of directives. There are a number of directives in the header/navigation each with there own scope. There is also a ng-repeat of 25 items and each one of those creates a directive each with its own scope.
One of the directives includes a form that includes a custom filter to display form errors, it looks like this:
Now the concern I have right now is that nagParseErrors is being executed about 33 times when anything in any scope changes even though this data createProjectForm.name is binded to (with ng-model) is only contained in the controller scope and the directive's scope containing the form (which is just being passed to the directive from the controller scope). I know it is related to the number of scopes (or directives) on the page because if I limit the ng-repeat from 25 items to 1, the filter is only called 9 times. This also happend for built-in filters (like json, and it even runs more times).
Is there something I might be doing wrong here or is this in fact how it should work in AngularJS?
BTW, I realize now that displaying the errors might be better off as a directive than a filter I am planning on going the directive route however I would like to clear up my understanding of filters here since I will probably run into this at some point down the road.
javascript - Angular.js 将过滤器传递给指令双向('=')属性
我需要sublist
在页面的几个地方使用指令,它有时应该包含完整fields
列表,但有时会被过滤。这是我天真的方法:
HTML:
Javascript:
当我尝试使用过滤器时,出现此错误:
这个问题有解决方案吗?
angularjs - angularjs - 如何从我定义的过滤器中调用标准过滤器?
Angular 带有一个称为“过滤器”的标准过滤器。我正在定义自己的过滤器,我想采取的第一步是使用包含的“过滤器”过滤器过滤我的列表——如何从我正在定义的新过滤器中访问它?
javascript - AngularJS 唯一过滤器然后更新所有记录
我的任务是使用 AngularJS 显示记录列表,如下所示:
并让用户能够通过他们所在的类别(或示例颜色)的复选框来显示/隐藏它们。因此,我使用 Angular-UI Unique 过滤器获取数据并显示了一些复选框,但是当我切换“红色”类别时,我想切换所有以“红色”为值的记录。
我猜我需要遍历记录并在复选框更改时手动执行是否有更多 Angular 方法可以做到这一点?
对于大型数据集,甚至使用 Angular 过滤器过滤掉 ng-repeat 中的结果,这也是一种很好的做法吗?
见小提琴http://jsfiddle.net/sjmcpherso/QXk9E/
问候
javascript - 使用 ng-repeat 有条件地应用过滤器
我有一个对象,其中包含值的数字和文本的混合。当它是一个数字时,我想将numbers
过滤器应用于对象的值(显然)。但是当它不是一个数字时,我会同意它只是吐出字符串。照原样,应用| number
到值格式化数字,但将字符串值留空(毕竟,它们不是数字)。
我猜它必须是一个自定义过滤器(我还需要制作)。有没有办法在执行时仅在 HTML 中执行ng-repeat
?
angularjs - 用于文本/数字的 AngularJS 自定义过滤器
我正在尝试为 AngularJS 编写我的第一个自定义过滤器。我希望能够识别某事物是字符串还是数字。如果它是一个数字,它会使用内置的 filter 对其进行格式化| number
。
我目前有一个解决方法ng-if
:
HTML
控制器:
我认为将其分配为自己的过滤器会是一个更好的解决方案。这就是我到目前为止所拥有的(是的,我知道这是最基本的......这是我的第一个)。
当它验证为数字时,我可以让它应用 Angular| number
过滤器吗?还是我需要自己手动使用 javascript 进行过滤?
angularjs - 如何在 AngularJS 中创建下拉过滤器结果
我在网页顶部有一个带有搜索栏的 Angular 应用程序。此搜索栏是显示 JSON 数据数组子集的过滤器。我希望此过滤器以不影响页面其余部分的 DOM 的方式显示其结果(这样,如果过滤器返回大量结果,则带有自己的滚动选项的下拉框将出现,而不是下推底层 HTML 页面的结果)。
我想出的解决方案是将我的和过滤器包装在一个 div 中,并在我的 CSS 中ng-repeat
给该 div 一个位置。absolute
有一个更好的方法吗?这对我来说似乎非常hackish并且不是很Angular,但我找不到任何其他下拉过滤器解决方案。