angularjsangularjs-ng-repeatangularjs-ng-optionsangularjs-select

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: by default pending status is selected and corresponding data is populated. let me know if further clarification is needed.


Solution

  • Declare a variable using $scope as:

    $scope.selected_request = "Pending";
    

    With this by default your intended data is selected.