我正在嘗試將api的數據顯示到下拉列表中(部門全名)。我可以顯示一個值,但不能顯示多個值。你能告訴我我哪裏錯了嗎?如何將不同數組中的多個值添加到下拉菜單中?
從json數組中,我想獲得值選擇下拉列表。我想進入下拉列表的數值是:,簡稱,學期和部分。我只能顯示shortName而不顯示其他2個值。
index.controller.js
$http.get('https://student.herokuapp.com/department/')
.success(function(response){
$scope.deptDetails=response.department;
// console.log($scope.deptDetails);
deptLen=response.department.sections.length;
console.log(deptLen);
for(var i=0;i<deptLen;i++){
$scope.deptDetails.push({"_id":response.department._id,
"shortName":response.department.shortName,
"section":response.department.sections[i].section,
"semester":response.department.sections[i].semester});
}
});
JSON數組
{
"department": {
"_id": "585955afce1a5e0011a2ecf5",
"collegeId": "58295efb836f8611d5e3e4cb",
"fullName": "Compcsuter Science",
"shortName": "CS",
"numberOfSemesters": "8",
"semesterYearScheme": "Semester",
"programName": "UG",
"numberOfSections": "1",
"sections": [
{
"_id": "585fb137bf29882207752552",
"collegeId": "585e53c6729e5c2214b97a0f",
"departmentId": "585fb137bf29882207752546",
"semester": 4,
"section": "C",
"syllabus": [],
"teachers": [],
"students": [],
"createdBy": "58332b90a7986c09b7e81980",
"createdAt": "2016-12-25T11:44:55.445Z",
"__v": 0
}
]
這裏是plnkr
在plunker其下拉菜單,你指的是? – Sajeetharan
@Sajeetharan對不起。我指的是出發件全名。 – HebleV