【问题标题】:Angular ng repeat filter, ignore when empty valueAngular ng重复过滤器,空值时忽略
【发布时间】:2016-04-21 06:03:38
【问题描述】:

我有这个选择

<select ng-model="applicationStatus" ng-options="p.StatusID as p.Status for p in vm.projects | unique:'StatusID'">
        <option value="">All</option>
 </select>

下面的列表使用选定的值作为过滤器:

<tr ng-repeat="p in vm.projects | filter: {StatusID:applicationStatus}">

这有效,除非在列表中选择“全部”(预定义值) 选择“全部”时,我不希望应用过滤器。实现这一目标的最佳方法是什么?

【问题讨论】:

    标签: angularjs filter angularjs-ng-repeat


    【解决方案1】:

    你可以有类似下面的东西,它将'' 空白而不是什么都没有。

    <tr ng-repeat="p in vm.projects | filter: {StatusID:(applicationStatus || '')}">
    

    【讨论】:

      【解决方案2】:

      您可能需要创建一个自定义过滤器来处理这种情况。这是一篇关于如何创建的好帖子:

      AngularJS filter by select with empty options

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-05-06
        • 2017-01-08
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多