對於我在ng-repeat
中迭代的每個對象,我都有一個或多個選擇框。用戶應該能夠從選擇框中選擇3個優先級並通過點擊按鈕進行保存。在保存功能中,我想訪問屬於選擇框的object.id和選擇的值。保存具有編號的多個選擇框的值
這裏是我當前的代碼以我的問題和問題的意見:
HTML
<div ng-repeat="object in objects">
<div>
<md-input-container>
<md-select ng-model="selectedPriority" placeholder="Priorität">
<md-option ng-value="{{ priority.name }}+{{ object.id }}" ng-repeat="priority in priorities">{{ priority.name }}</md-option> <!--setting of ng-value throws an error? How can I do this?-->
</md-select>
</md-input-container><br>
{{ object.id}}
</div>
</div>
<md-button ng-click="save()">Save</md-button>
控制器
$scope.save = function() {
console.log($scope.selectedPriority); //Here I want to get all object.id with selected value but it is undefined
}
@Sajeetharan:對象JSON具有以下表格
JSON
[{
"date":"2017-01-21T18:20:00.873Z",
"duration":120,
"location":"Test",
"passed":false,
"id":"58838763019ac0479455bbc0"
},
{
"date":"2017-01-21T15:15:00.420Z",
"duration":10,
"location":"Test",
"passed":false,
"id":"58839ac9019ac0479455bbc1"
}
//...]
發表您的對象JSON – Sajeetharan
什麼是優先級排列 – Sajeetharan