我正在使用angularJS。我必须如下所示填充两个下拉列表。一个是Class,另一个是Section。 一个类可以有多个部分。 我希望根据班级选择来自班级下拉菜单,部分下拉菜单仅显示该班级的部分。
classes = [
{"academicYear":"2015","classId":"1","classStd":"Prep-2015"},
{"academicYear":"2015","classId":"3","classStd":"NUR"},
{"academicYear":"2015","classId":"4","classStd":"STD-1"}
]
section = [
{"academicYear":"2015","sectionId":"5","classId":"1","section":"A","sectionName":"ROSE"},
{"academicYear":"2015","sectionId":"6","classId":"1","section":"B","sectionName":"RED"},
{"academicYear":"2015","sectionId":"7","classId":"1","section":"C","sectionName":"green"},
{"academicYear":"2015","sectionId":"8","classId":"3","section":"A","sectionName":"ROME"},
{"academicYear":"2015","sectionId":"9","classId":"3","section":"B","sectionName":"PARIS"}
]
Class DropDown
<div class="col-md-4">
<select class="form-control" id="inputclassId" name="inputclassId"
ng-model='subjectAllocation.classId'
ng-options="classList.classId as classList.classStd for classList in vm.classList"
required >
</select>
</div>
Section DropDown
<div class="col-md-4">
<select class="form-control" id="inputsectionId" name="inputsectionId"
ng-model='subjectAllocation.sectionId'
ng-options="sectionList.sectionId as sectionList.sectionName for sectionList in vm.sections"
required >
</select>
</div>
答案 0 :(得分:0)
在ngRepeat中,使用过滤器仅显示与正确的classId对应的部分。
firstdate = [[NSCalendar currentCalendar] dateByAddingUnit:NSCalendarUnitDay value:-5 toDate:[NSDate date] options:nil];
您可能还希望确保某人不输入课程,然后输入某个部分,然后更改他们的课程。您可以使用监视语句来执行此操作。
<select class="form-control" id="inputclassId" name="inputclassId"
ng-model='subjectAllocation.classId'
ng-options="classList.classId as classList.classStd for classList in vm.classList"
required >
</select>
<div class="col-md-4">
<select class="form-control" id="inputsectionId" name="inputsectionId"
ng-model='subjectAllocation.sectionId'
ng-options="sectionList.sectionId as sectionList.sectionName for sectionList in vm.sections | filter:{classId:subjectAllocation.classId}"
required >
</select>
</div>