如果需要使用两个模型,如何从ng-options获取数据?

时间:2015-06-02 11:44:33

标签: angularjs ng-options

我做了一个简单的例子:http://codepen.io/anon/pen/VLpYJm?editors=101

在这个例子中,我需要获得field.type并将其与ng-switch一起使用。

<div ng-app="app">

  <table ng-controller="tableController">
    <tr ng-repeat="item in items">
        <td>
          {{item}}
        </td>
        <td>
            <select ng-model="item" ng-options="field.label for field in fields track by field.name" required="required" />
        </td>
        <td>
            <div ng-switch on="item.type">
                <div ng-switch-when="BOOLEAN">
                    <input ng-model="item.value" type="checkbox" />
                </div>
                <div ng-switch-default>
                    <input ng-model="item.value" type="text" class="form-control" required="">
                </div>
            </div>
        </td>
        <td>{{selected}}</td>
    </tr>
  </table>

</div>

0 个答案:

没有答案