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

georgeawg
  • 48,608
  • 13
  • 72
  • 95
user7353226
  • 55
  • 2
  • 8
  • 1
    Not clear both what the problem is and what the desired result might be. Please clarify. – Jax Dec 29 '16 at 09:21
  • There is dropdown if i select approved as status, the corresponding data should populate the table. Works fine till here. but the prob is the approved status should be "by default" selected and data should be populated in table. – user7353226 Dec 29 '16 at 10:09
  • https://jsfiddle.net/wLd182gx/ – user7353226 Dec 29 '16 at 10:21

2 Answers2

0

Declare a variable using $scope as:

$scope.selected_request = "Pending";

With this by default your intended data is selected.

Sai M.
  • 2,548
  • 4
  • 29
  • 46
0

Please made changes in your select tag like below. It will make "approved" selected by default and also populate your table according to selection. Hope it will help.

   <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> 
Divya Jain
  • 393
  • 1
  • 6
  • 22