将ng-select值作为对象接收

时间:2015-06-05 04:46:28

标签: angularjs node.js

HTML

<select ng-model="data.trackId" 
    ng-value="track.id" 
    ng-options="track.name for track in tracks">
</select>

在服务器端我正在接收该轨道作为对象。

{ name: 'gadf',
  room: 'asdf',
  start: '0:55',
  end: '0:55',
  dayId: 4,
  trackId: { id: 3, name: 'track 3', color: '#FFFFCC' },
  color: 'gasdf',
  description: 'asdf' }

期望:

我想收到trackId为3

1 个答案:

答案 0 :(得分:0)

ng-value没有必要,请尝试:

<select ng-model="data.trackId" 
    ng-options="track.trackId.id as track.name for track in tracks">
</select>

更新: Demo