Javascript 如何使选择列表修改angular.js中的属性

Javascript 如何使选择列表修改angular.js中的属性,javascript,angularjs,angularjs-ng-repeat,Javascript,Angularjs,Angularjs Ng Repeat,我有一个设备数组,每个设备都包含操作。我使用嵌套的ng repeats列出所有设备,并提供包含所有操作的选择列表。如何在设备上创建始终表示当前选定操作的属性?以下是我目前拥有的代码: <div class="span5 outputDevices well" droppable> Drag a device here for output <div class="droppedDevice" ng-repeat="outputDevice in outpu

我有一个设备数组,每个设备都包含操作。我使用嵌套的ng repeats列出所有设备,并提供包含所有操作的选择列表。如何在设备上创建始终表示当前选定操作的属性?以下是我目前拥有的代码:

  <div class="span5 outputDevices well" droppable>
    Drag a device here for output

    <div class="droppedDevice" ng-repeat="outputDevice in outputDevices" >
      <h1>{{outputDevice.fields.baseDevice.fields.name}}</h1>

      <button class="btn btn-danger" ng-click="removeDevice('output', $index)">
          X
      </button>

      <select class="outputActions">
        <option>
          Select Action
        </option>
        <option ng-repeat="action in outputDevice.fields.baseDevice.fields.outputs">
          {{action.fields.name}}
        </option>
      </select>

    </div>
  </div>

将设备拖到此处进行输出
{{outputDevice.fields.baseDevice.fields.name}
X
选择动作
{{action.fields.name}
编辑:我已尝试根据下面的评论修改我的选择,但是这些操作现在似乎根本没有重复:

      <select class="inputActions" ng-options="action.fields.name for action in inputDevice.fields.baseDevice.fields.inputs">
        <option value="">
          Select Action
        </option>
      </select>

选择动作

您需要在
选择
上有一个
ngModel
指令,如下所示:

<select class="outputActions" ng-model="outputDevice.action"
        ng-options="action.fields.name for action in outputDevice.fields.baseDevice.fields.inputs">
    <option value="">
      Select Action
    </option>
</select>

选择动作

这样,如果选择了一个动作,<代码> OutPuth.Action 将被设置为所选的动作。

您可以考虑使用SELECT和NGOPTION指令,而不是NGRPEAT也可以发布您的应用程序代码吗?可能在fiddle/plunker演示中,在原始代码中是“outputDevice中的操作…”,但在修改后的代码中是“inputDevice中的操作…”,您可能需要对此进行检查。