0

I need to configure one of the columns in my smart-table to be a dropdown. The possible values for the 'Status' column are OK and PENDING. (These values are retrieved from a rest api) I am looking to initialize the value in the dropdown to OK/PENDING based on the value retrieved from the api.

I posted what I've tried so far,the status are all set to OK regardless of the actual value.

I'm just starting out with smart-table and javascript so any help is appreciated.

For reference, here is a sample json object being returned from my rest api (other fields removed):

[
 {
   comments: [
   {
     comment: "Test comment",
     userId: "test_user",
     timestamp: 1473282222280
   }
  ],
  status: "PENDING"
}]

Here is the smart-table html code:

  <tbody>
     <tr ng-repeat="row in rowCollection" ng-class="{danger: (row.status=='PENDING'),success:(row.status=='OK')}">
        <td cs-select="row"></td>
        <td align="center">
        <select st-search="status">
           <option value="">OK</option>
           <option value="">PENDING</option>
           <!-- <option ng-repeat="row in rowCollection | unique:'status'" value="{{row.status}}">{{row.status}}</option> -->
        </select></td>
        <td align="center">{{row.comments[0].comment}}</td>
  </tbody>

and a screenshot of the table: Screenshot

1 Answer 1

1

You can try with the ng-selected directive in this way:

<select>
 <option ng-selected="row.status == 'PENDING'">PENDING</option>
 <option ng-selected="row.status == 'OK'">OK</option>
</select>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.