Javascript 以动态ng模型为对象使用嵌套ng repeat

Javascript 以动态ng模型为对象使用嵌套ng repeat,javascript,html,angularjs-scope,angularjs-ng-repeat,Javascript,Html,Angularjs Scope,Angularjs Ng Repeat,好吧,老实说,我是一个角度的初学者,我不知道如何界定这个问题,我会尽力解释这个问题 图1: 正如你在上面的图片中看到的,我有一个类列表,每个类下面都没有任何部分。你可以在每一行上看到一个蓝色按钮,我需要知道选择了哪个“部分” 这是问题陈述 现在,这里是我的HTML为这个 <table class="table table-hover"> <tbody> <tr> <th>Syllabus</th>

好吧,老实说,我是一个角度的初学者,我不知道如何界定这个问题,我会尽力解释这个问题

图1:

正如你在上面的图片中看到的,我有一个类列表,每个类下面都没有任何部分。你可以在每一行上看到一个蓝色按钮,我需要知道选择了哪个“部分”

这是问题陈述

现在,这里是我的HTML为这个

<table class="table table-hover">
  <tbody>
    <tr>
      <th>Syllabus</th>
      <th>{{phrase.className}}</th>
      <th>Select Section</th>
      <th>{{phrase.Operations}}</th>
    </tr>
    <tr ng-repeat="class in classes| filter:searchText">
      <td id="syl">
        <span ng-repeat="(sid, syllabi)  in syllabus" ng-if="sid == class.classAcademicYear">
            {{ syllabi.yearTitle}}
        </span>
      </td>
      <td id="cls">{{class.className}}</td>
      <td id="sec">
        <div class="form-group">
          <select class="form-control" name="student_section" ng-model="selectedSection">
             <option ng-selected='class.sections[$index].id' ng-repeat="(key, section) in class.sections" value="{{section.id}}">{{section.sectionName}}</option>
          </select>
        </div>
      </td>
      <td id="vew">
        <button ng-click="edit(class.id)" type="button" class="btn btn-info btn-flat" title="{{phrase.ReadSchedule}}" tooltip><i class="fa fa-fw fa-th-list"></i></button>
      </td>
    </tr>
    <tr ng-show="!classes.length">
      <td class="noTableData" colspan="3">{{phrase.NoClasses}}</td>
    </tr>
  </tbody>
</table>
我试图做的是为动态的内部选择下拉元素设置一个ng模型,如下所示,这样每次选择分区时,我都可以将蓝色按钮操作设置为任何分区id

ng model=“selectedSection[class.id]”

这是行不通的


我知道这可能是不够的信息,但如果有人有兴趣帮助我解决这个问题,我可以分享进一步的细节

要检查选择了哪一个ng repeat行,您应该发送值$index和$parent.$index(如果您有嵌套的ng repeat)



有帮助吗?

要检查选择了哪一个ng repeat行,您应该发送值$index和$parent.$index(如果您有嵌套的ng repeat)



它有帮助吗?

如果你给出一个工作代码(比如jsbin或类似的东西),效果会更好。如果你给出一个工作代码(比如jsbin或类似的东西),效果会更好。$parent.$index是未定义的!&我们可以访问第二个ng重复的$index吗?我的意思是,按钮必须位于ng repear isnt'tof课程中,您的ng click属性和$index、$parent.$index应该位于第二个循环中。为什么我要将按钮放在选项循环中?让我们在jsbin上创建一个工作示例。我会尽力帮忙。$parent.$index未定义!&我们可以访问第二个ng重复的$index吗?我的意思是,按钮必须位于ng repear isnt'tof课程中,您的ng click属性和$index、$parent.$index应该位于第二个循环中。为什么我要将按钮放在选项循环中?让我们在jsbin上创建一个工作示例。我会尽力帮忙的。
[{
  "id": 11,
  "className": "Class-1 (STATE)",
  "classAcademicYear": 2,
  "classSubjects": "[\"1\",\"2\",\"3\",\"4\",\"5\",\"6\"]",
  "dormitoryId": null,
  "sections": [{
    "id": 11,
    "sectionName": "Section -1 (STATE)",
    "sectionTitle": "section title -1",
    "classId": 11,
    "teacherId": "[\"10\",\"11\",\"12\",\"13\",\"14\",\"15\"]"
  }]
}, {
  "id": 12,
  "className": "Class-2",
  "classAcademicYear": 2,
  "classSubjects": "[\"0\"]",
  "dormitoryId": null,
  "sections": [{
    "id": 12,
    "sectionName": "Section -1",
    "sectionTitle": "section title -1",
    "classId": 12,
    "teacherId": "[\"0\"]"
  }]
}, {
  "id": 13,
  "className": "Class-3",
  "classAcademicYear": 2,
  "classSubjects": "[\"0\"]",
  "dormitoryId": null,
  "sections": [{
    "id": 13,
    "sectionName": "Section -1",
    "sectionTitle": "section title -1",
    "classId": 13,
    "teacherId": "[\"0\"]"
  }]
}, {
  "id": 14,
  "className": "Class-4",
  "classAcademicYear": 2,
  "classSubjects": "[\"0\"]",
  "dormitoryId": null,
  "sections": [{
    "id": 14,
    "sectionName": "Section -1",
    "sectionTitle": "section title -1",
    "classId": 14,
    "teacherId": "[\"0\"]"
  }]
}]
<button ng-click="edit($index, $parent.$index)" type="button">