保存后在下拉列表中设置所选值

时间:2016-10-25 07:51:07

标签: javascript html angularjs

我需要在db中保存数据后显示下拉列表的选定值。 下面是我的代码。

<table>
  <tr ng-repeat="customer in user.customers track by $index">
    <td class="tableTd" ng-show="customer.quoteApprovalLevels">{{customer.ic01}} ({{customer.customerName}})</td>
    <td class="tableTd" ng-show="customer.quoteApprovalLevels">
      <select ng-model="user.customers[$index].userQuoteApprovalLevel.approvalLevel">
        <option ng-repeat="approvalLevel in customer.quoteApprovalLevels" value="{{approvalLevel.approvalLevel}}">
          {{approvalLevel.approvalLabel}} - {{approvalLevel.approvalLevel}}
        </option>
      </select>
  </tr>
</table>

js代码是

$scope.user = Administration.save($scope.user, function (data, httpResponse)     
{
}

1 个答案:

答案 0 :(得分:0)

<table>
  <tr ng-repeat="customer in user.customers track by $index">
    <td class="tableTd" ng-show="user.customers[$index].userQuoteApprovalLevel.approvalLevel">{{customer.ic01}} ({{customer.customerName}})</td>
    <td class="tableTd" ng-show="customer.quoteApprovalLevels">
      <select ng-model="user.customers[$index].userQuoteApprovalLevel.approvalLevel">
        <option ng-repeat="approvalLevel in customer.quoteApprovalLevels" value="{{approvalLevel.approvalLevel}}">
          {{approvalLevel.approvalLabel}} - {{approvalLevel.approvalLevel}}
        </option>
      </select>
  </tr>
</table>