您好我正在使用AngularJS來更新多個實體(您稱之爲頁面)。這些實體具有我希望用戶通過選擇下拉列表選擇的標籤。當我獲取實體集合的數據時,我獲取已經選擇的標籤並將其存儲在該元素的數組中。AngularJS從np-repeat中選擇加載選定的值
我已經有了一個演示,我已經填充了所有選項的列表以及我在ng-repeat中輸出實體數據的選擇,但是我無法傳入已經選擇的選項。
我的代碼如下;
<div ng-app="app">
<div ng-controller="Controller">
<div ng-repeat="entity in tasks.entities">
<input class="form-control" type="text" name="entity['{{entity.data.UID}}']" ng-model="entity.data.name" />
<select ng-model="entity.data.selected_tags.effort" ng-options="effort as effort.value group by effort.category for effort in effortTags"></select>
</div>
</div>
</div>
正如你所看到的,我試圖訪問select中的ng模型中的entity.data.selected_tags.effort。 entity.data.selected_tags.effort對應下面的角度控制器中的$ scope.tasks中存在的數據。
angular.module('app', [])
.controller('Controller', function($scope) {
$scope.effortTags = [{
category: "5. XS",
id: "94",
value: "01:00:00"
}, {
category: "4. S",
id: "96",
value: "02:00:00"
}, {
category: "3. M",
id: "94",
value: "04:00:00"
}, {
category: "2. L",
id: "94",
value: "07:00:00"
}, {
category: "1. XL",
id: "94",
value: "16:00:00"
}, {
category: "0. XXL",
id: "94",
value: "38:00:00"
}, {
id: "105",
value: "Estimate Required"
}];
$scope.tasks = {
"entities": {
"Agree_a_standard_team_approach_to_logging_and_document_it__1285": {
"data": {
"id": "3311",
"name": "Agree a standard team approach to logging, and document it.",
"UID": "Agree_a_standard_team_approach_to_logging_and_document_it__1285",
},
"selected_tags": {
"importance": [{
"id": "1",
"value": "0. Must"
}],
"status": [{
"id": "13",
"value": "Open"
}],
"clientprojects": [{
"id": "67",
"value": "House"
}, {
"id": "697",
"value": "All"
}],
"effort": [{
"id": "105",
"value": "Estimate Required"
}],
"sprint": [{
"id": "107",
"value": "CD"
}],
"type": [{
"id": "159",
"value": "Feature"
}]
}
},
"Apply_error_handling_solution_to_project": {
"data": {
"id": "2994",
"name": "Apply solution to error handling on all project",
"UID": "Apply_error_handling_solution_to_project",
},
"selected_tags": {
"importance": [{
"id": "2",
"value": "1. Must"
}],
"status": [{
"id": "13",
"value": "Open"
}],
"clientprojects": [{
"id": "67",
"value": "House"
}, {
"id": "697",
"value": "All"
}],
"effort": [{
"id": "105",
"value": "Estimate Required"
}],
"sprint": [{
"id": "707",
"value": "CD5"
}],
"type": [{
"id": "159",
"value": "Feature"
}]
}
}
}
};
});
任何想法如何才能得到在這個重複選定的選項?
你必須做出一些選擇在表單運行正確時選擇,或者你說一些話 –
是的,我想在表單運行時得到選定的選項@PareshGam我 – 001221
哪個選項?你必須做出選擇? –