Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 使用ng repeat更改折叠面板内容_Angularjs - Fatal编程技术网

Angularjs 使用ng repeat更改折叠面板内容

Angularjs 使用ng repeat更改折叠面板内容,angularjs,Angularjs,我有一个项目列表,在每个项目中都有许多任务,我的想法是使用一个折叠面板,其中标题是项目名称,内容是任务信息,我面临的唯一问题是元素的id,因此在最后,结果是混合的,我的代码如下: <div ng-repeat= "projet in projetsactifs track by $index" > <div class="panel-group" id="accordion{{$index}}"> <div class="panel panel-info"&g

我有一个项目列表,在每个项目中都有许多任务,我的想法是使用一个折叠面板,其中标题是项目名称,内容是任务信息,我面临的唯一问题是元素的id,因此在最后,结果是混合的,我的代码如下:

 <div ng-repeat= "projet in projetsactifs track by $index" >
 <div class="panel-group" id="accordion{{$index}}">
 <div class="panel panel-info">
 <div class="panel-heading">
 <h4 class="panel-title">
 <a  href="#{{$index}}l" ng-click="tasks(projet.IdProjet)" data-toggle="collapse" data-parent="#accordion{{$index}}" >
 {{projet.NomProjet}}</a>
 </h4>
 </div>
  <div id="{{$index}}l" class="panel-collapse collapse in">
  <div class="panel-body">
  <div class="table-responsive">
    <table class="table table-bordered table-hover table-striped">
      <thead>
      <tr>
      <th>Task</th>
      <th>Date</th>
      <th>price (€/day)</th>   
      </tr>
      </thead>
      <tbody>
      <tr ng-repeat="tache in tachelistes | orderBy: 'NomTache'">
      <td>{{tache.NomTache}}</td>
      <td>{{tache.Delai | date : 'dd/MM/yyyy'}}</td>
      <td>{{tache.CoutParJour}}</td>
      </tr>
      </tbody>
    </table>
  </div>
</div> 
</div>
</div>
</div>
</div>

下面是一个例子:

对于您的第一期,您需要筛选每个项目的任务,您可以使用内置循环,如下所示:

<tr ng-repeat="tache in tachelistes | filter: {projet_id:projet.IdProjet} | orderBy: 'NomTache'">
这将匹配索引$index处的hiddenBody数组。当计算为truthy时,定义ng show的元素将变为可见

ngShow指令基于以下内容显示或隐藏给定的HTML元素: 提供给ngShow属性的表达式

我没有尝试在单击时过滤任务数组,而是在单击时定义hiddenBody的值。ng click=hiddenBody[$index]=!hiddenBody[$index]


检查我进行修改的Plunker。

谢谢,这是有效的,只是我必须更改ng click=hiddenBody[$index]=!hiddenBody[$index]到ng单击=hiddenBody[$index]=hiddenBody[$index]和ng显示=!hiddenBody[$index]我的印象是,如果您单击项目标题(我的代码就是这样做的),您希望切换每个项目的任务面板。但我很高兴你自己做了一些改变。不客气。
<tr ng-repeat="tache in tachelistes | filter: {projet_id:projet.IdProjet} | orderBy: 'NomTache'">
ng-show="hiddenBody[$index]"