默认查看 table 中的未决状态数据

view pending status data in table by default

<select class="form-control" id="selectrequest" ng-model="selectedrequest">

                        <option value="pending" > Pending </option>
                        <option value="approved"> Approved </option>
                        <option value="rejected"> Rejected </option>
                    </select>


<tr ng-repeat="mymodel in vm.modelname  | filter:selectedrequest">
                        <td>{{mymodel.name}}</td>
                        <td>{{mymodel.triggername}}</td>
                        <td>{{mymodel.status}}<td>
                    </tr>

vm.modelname=[{
    name:'Peter',
    triggername:'Peter1',
    status:pending
},{
    name:'Jack',
    trigger name:'Jack Hein',
    status:approved
}]

Prob stint:默认情况下选择待定状态并填充相应的数据。如果需要进一步说明,请告诉我。

使用 $scope 声明一个变量为:

$scope.selected_request = "Pending";

默认情况下选择您想要的数据。

请对您的 select 标签进行如下更改。默认情况下,它会生成 "approved" selected 并根据 selection 填充您的 table。 希望它会有所帮助。

   <body>
      <h2>AngularJS Sample Application</h2>

      <div ng-app="mainApp" ng-controller="studentController">
        <select class="form-control" id="selectrequest" ng-init="selected_request='approved';selected_requested()" ng-model="selected_request" ng-change="selected_requested()">

          <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>