dongtang1997 2016-08-31 06:15
浏览 74

使用angularjs的单个功能中的多个过滤器

I try to filter two values like this | filter:{voucher_type: selectedName } | filter:{voucher_type: both }

Here both is "B" and selectedName "P or R". Below code work only one filter only.

I want to combine this two filter values together and show the result like voucher_type B + P (Or) R.

<html>
  <head>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.min.css"/>
    <title>search</title>
  </head>
  <body>
    <div class="row">
      <div class="container">
        <div class="col-sm-9">
          <div ng-app="myApp">
            <script type="text/ng-template" id="search">
              <a>
                        <span bind-html-unsafe="match.label | typeaheadHighlight:query"></span>
                  <i> {{match.model.sub_name}} -({{match.model.group_name}}) </i>
              </a>
            </script>
            <form class="form-search" ng-controller="autocompleteController">
              Selected Ledger: {{selectedLedgers}} <br>
              <br>
              <!--          typeahead="c as c.ledger_id + '-' + c.ledger_name + ' <i>(' +c.group_name + ')</i>'-->
              <input type="text" ng-model="both"></p>
              <div>select voucher :<select ng-model="selectedName" ng-options="x for x in names">
                </select>
              </diV>
              <input type="text" ng-model="selectedLedgers" placeholder="Search Ledger" typeahead="c as c.ledger_id +  '-'+ c.ledger_name for c in producers | filter:$viewValue| limitTo:20 | filter:{voucher_type: selectedName1 } | filter:{voucher_type: both }" typeahead-min-length='2' typeahead-on-select='onSelectPart($item, $model, $label)' typeahead-template-url="search" class="form-control" style="width:350px;">
              <i class="icon-search nav-search-icon"></i>
            </form>
          </div>
        </div>
      </div>
    </div>
    <script type="text/javascript" src="js/angular.min.js"></script> 
    <script src="js/ui-bootstrap-tpls-0.9.0.js"></script> 
    <script type="text/javascript">
      var app = angular.module('myApp', ['ui.bootstrap']);

      app.controller('autocompleteController', function($scope, $http) {

        $http.get("getLedgers.php").success(function(data){
              $scope.producers = data;
             });

        $scope.names = ["P", "R"];
            $scope.filters = {
              x: false,
          company: '',
              search: ''
          };
          $scope.both ='B';

      });
    </script>
  </body>
</html>

Find my demo project here https://jsfiddle.net/basilbkodakk/sk549x4m/2/ .there have 3 company x,y,z .list box show x and y . z is common for x,y .that filter method in angularjs

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 测距传感器数据手册i2c
    • ¥15 RPA正常跑,cmd输入cookies跑不出来
    • ¥15 求帮我调试一下freefem代码
    • ¥15 matlab代码解决,怎么运行
    • ¥15 R语言Rstudio突然无法启动
    • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
    • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
    • ¥15 用windows做服务的同志有吗
    • ¥60 求一个简单的网页(标签-安全|关键词-上传)
    • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法