【问题标题】:angularjs ngrepeat not filtering by datepicker valueangularjs ngrepeat 不按日期选择器值过滤
【发布时间】:2013-08-02 11:31:26
【问题描述】:

我正在尝试根据日期过滤行作为标准。 使用输入类型日期作为搜索条件之一,并根据属性名称过滤行不起作用。

ex - <input type="date" ng-model="searchc_date" name="dtCsltDoctor"> <li ng-repeat="cs in consultations|filter:searchc_date"> 没有产生任何结果。我将数据更改为相同的格式。没有匹配的行。

Fiddle for the code

【问题讨论】:

    标签: angularjs uidatepicker angularjs-ng-repeat


    【解决方案1】:

    问题仍然在于您的日期格式。因为 JS 中的日期只是一种痛苦,所以每当我进行比较时,我通常会使用像 moment.js 这样的库来格式化日期,以便让它们匹配。

    <pre>fake code to get past SO's requirement</pre>
    

    这可行:http://jsfiddle.net/6432E/8/

    【讨论】:

    • 谢谢莎朗迪奥,你是对的。 Moment 确实为我同步了日期。但我曾经在 Mongo 中以“日期格式”存储数据。我会将它们转换为字符串并在模型中对其进行操作。谢谢,这行得通。欣赏它。
    • 只要记住当你把它们放回 Mongo 时,将它们保存为 new Date()。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-04-22
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多