在Angular中按复选框过滤项目

时间:2016-12-21 13:53:12

标签: javascript angularjs checkbox

需要点击数组中的复选框来过滤项目。这是我尝试做的事情

    <thead>

    <th><input ng-model="archived.state"  type="checkbox">Show archived</th>

    </th>
<tbody>
      <tr  ng-repeat="paymentinfo in paymentList | filter:keyword | filter:money | filter:getdate | filter:archived">
          <td>{{paymentinfo.date}}</td>
          <td ng-click="singlepage(paymentinfo.id)" ><a>{{paymentinfo.name}}</a> </td>
                  <td>
                      <div class="grey-flag remark-payment">
                          <div class="hover-remark">{{paymentinfo.remark}}</div>
                      </div>
                  </td>
          <td>$ {{paymentinfo.amount}}</td>
          <td id="outmouse">
              <ul  style="list-style: none;" class="gt-reset">
                <li class="dropdown changecoursename">
                    <a   class="dropdown-toggle" data-toggle="dropdown">
                        <span class="tableOperation norlmalstate">Open Course</span>
                    <span  class="tableOperation openedstate">more options</span>
                    <b class="caret"></b>
                </a>
                <ul class="dropdown-menu">
                    <li><a class="tableOperation" ng-click="paymentRemarks()">Remarks</a></li>
                    <li><a class="tableOperation" ng-click="paymentReturn(paymentinfo)">Return</a></li>
                    <li><a class="tableOperation" ng-click="paymentDelete(paymentinfo)">Delete</a></li>

                </ul>
              </li>
          </ul>
          </td>
      </tr>  

我的JS

$scope.datas = [
        {date:'06-12-2016', name : 'Pinao Class', state: 'archived', remark : 'remarled', amount : 101, id : 21},
        {date:'15-04-2016', name : 'drivers Class', state: 'notarchived', remark : 'remarled', amount : 102, id : 22},
        {date:'24-03-2016', name : 'Airplane Class', state: 'archived', remark : 'remarled', amount : 103, id : 23},
        {date:'28-02-2016', name : 'burger Class', state: 'notarchived', remark : 'remarled', amount : 104, id : 24},
         {date:'28-02-2016', name : 'burger Class1', state: 'notarchived', remark : 'remarled', amount : 104, id : 241},
          {date:'28-02-2016', name : 'burger Class2', state: 'notarchived', remark : 'remarled', amount : 104, id : 2432},
           {date:'28-02-2016', name : 'burger Class3', state: 'notarchived', remark : 'remarled', amount : 104, id : 2342},
            {date:'28-02-2016', name : 'burger Class4', state: 'archived', remark : 'remarled', amount : 104, id : 2443},
             {date:'28-02-2016', name : 'burger Class5', state: 'archived', remark : 'remarled', amount : 104, id : 2243},
              {date:'28-02-2016', name : 'burger Class6', state: 'archived', remark : 'remarled', amount : 104, id : 2242},
  ];

  $scope.paymentList = $scope.datas;

如何创建我点击的过滤器以及所有具有字段状态的项目:'notarchived',将显示?并且在取消选中后,所有项目都会再次显示

1 个答案:

答案 0 :(得分:1)

也许试试这个

HashMap<String, String> params = new HashMap<String, String>();

public void JSON_DATA_WEB_CALL() {
        jsonArrayRequest = new JsonArrayRequest(GET_JSON_DATA_HTTP_URL, new JSONObject(params),
                new Response.Listener<JSONArray>() {
                    @Override
                    public void onResponse(JSONArray response) {

                        JSON_PARSE_DATA_AFTER_WEBCALL(response);
                    }
                },
                new Response.ErrorListener() {
                    @Override
                    public void onErrorResponse(VolleyError error) {

                    }
                }){
            @Override
            public Map<String, String> getHeaders() throws AuthFailureError {
                HashMap<String, String> headers = new HashMap<String, String>();
                headers.put("CUSTOM_HEADER", "Yahoo");
                headers.put("ANOTHER_CUSTOM_HEADER", "Google");
                return headers;
            }
        };
        requestQueue = Volley.newRequestQueue(this);
        requestQueue.add(jsonArrayRequest);
    }