默认情况下如何 select table 查看挂起

how to select table view pending by default

HTML

<select class="form-control" id="selectrequest" ng-model="selected request" ng-change="vm.selected_requested()">
    <option value="pending" > Pending </option>
    <option value="approved"> Approved </option>
    <option value="rejected"> Rejected </option>
</select>

JS

vm.model=[{
    name:'abc',
    lastname:'xyz',
    status:pending
}]

//默认需要select个pending items vm.selected_requested = 函数 (){

}

在 selected_requested 函数中使用 angular 过滤器根据所选选项过滤项目。或者您可以使用 $filter 创建自定义过滤器。参考文档https://docs.angularjs.org/api/ng/filter/filter

    angular.module('FilterInControllerModule', []).
        controller('FilterController', ['$scope','filterFilter', function($scope,filterFilter) {
          $scope.data=[]; //use your table data.
         vm.selected_requested = function (){


          $scope.filteredArray = filterFilter($scope.data, {status:selected request});

} 
        }]);

您好,我已经按照您的要求实现了这个功能。现在您可以从视图以及控制器中看到过滤示例。如果您需要任何进一步的帮助,请告诉我

  var mainApp = angular.module("mainApp", []); 
       mainApp.controller('studentController', function($scope,filterFilter) {
        var vm = $scope;
         $scope.model=[{ name:'abc_pending', lastname:'xyz', status:"pending" },
                     { name:'abc1_pending', lastname:'xyz', status:"pending" },
                     { name:'abc2_approved', lastname:'xyz', status:"approved" },
                     { name:'abc3_rejected', lastname:'xyz', status:"rejected" }];   
         
         vm.filteredArray = []; 
         vm.selected_requested = function (){
           vm.filteredArray = filterFilter($scope.model, {status:$scope.selected_request});
        
         }
          });
<html>
   
   <head>
      <title>Angular JS Controller</title>
      <script src = "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"></script>
   </head>
   
   <body>
      <h2>AngularJS Sample Application</h2>
      
      <div ng-app = "mainApp" ng-controller = "studentController">
        <select class="form-control" id="selectrequest" ng-model="selected_request" ng-change="selected_requested()">
                    <option value="" > All </option>
                    <option value="pending" > Pending </option>
                    <option value="approved"> Approved </option>
                    <option value="rejected"> Rejected </option>
                </select> 
        <div ng-repeat = "temp in model | filter:(!!selected_request || undefined) && {status: selected_request} ">
           <span ng-bind ="temp.name">
             </span>
           </div>
        <br/>
       Items in filtered Array <br/>
     <div ng-repeat = "temp in filteredArray">
           <span ng-bind ="temp.name">
             </span>
           </div>
      </div> 
      
   </body>
</html>