tr 中的单个 th ng-repeat

single th in tr with ng-repeat

我不能用 ng-repeat 显示 tr 中第一个元素的值吗?

这就是我的 html 的样子

<div class="center layout-column flex">
<section layout="row" layout-align="left left">
  <md-button class="md-primary" ng-click="vm.showDialogAdd($event)">Add new movie</md-button>
  <md-button class="md-primary" ng-click="vm.showDialogDetails($event)">Add details</md-button>
</section>
    <div class="simple-table-container md-whiteframe-4dp">
      <div class="ms-responsive-table-wrapper">
        <table class="simple" ms-responsive-table>
          <thead>
            <tr>
              <th>Title</th>
              <th>Year</th>
              <th>Country</th>
              <th class="text-center">Action</th>
            </tr>
          </thead>
          <tbody>
            <tr ng-repeat-start="movie in vm.movies">
              <td>{{ movie.title }}</td>
              <td>{{ movie.year }}</td>
              <td>{{ movie.country }}</td>
              <td class="text-center">
                <md-button class="md-warn" ng-click="vm.deleteMovie(movie)">Remove</md-button>
                <md-button class="md-noink" ng-click="vm.showDetails(movie)">Details</md-button>
              </td>
            </tr>
            <tr ng-repeat-end ng-show="movie._detailsVisible" ng-repeat="detail in vm.movieDetails">
              <th>Actors: </th>
              <td>
                {{ detail.name }}
              </td>
            </tr>
          </tbody>
        </table>
      </div>
    </div>
</div>

我想显示 "Actors:" 就像所有 tds 的标题一样:

我该怎么做?

我不知道你在一个td中显示"Actors:"是什么意思,但你可以尝试将它添加在详细名称前面,这样它就会在一个td中显示值.

编辑:请尝试以下代码来实现您的要求。

<tr ng-repeat-end ng-show="movie._detailsVisible">
  <th>
       Actors:
  </th>
  <td ng-repeat="detail in vm.movieDetails">
    {{ detail.name }}
  </td>
</tr>

只需将ng-repeat移动到td

<tr ng-repeat-end ng-show="movie._detailsVisible">
      <th>Actors: </th>
      <td ng-repeat="detail in vm.movieDetails">
        {{ detail.name }}
      </td>
</tr>