ng-repeat内部的角度ng重复在表格中不起作用

时间:2022-12-02 15:31:22

I have the following

我有以下内容

 <tbody ng-repeat="history in orderHistory">
        <tr>
            <td>{{history.reference_code}}</td>
            <div ng-repeat="items in history.orderedItems">
                <td>{{items.product_description}}</td>
                <td>{{items.quantity}}</td>
            </div>
            <td>
        </tr>
</tbody>

it seems that the second ng-repeat is not working and {{items.quantity}} or items . anything does not end up showing.

似乎第二次ng-repeat不起作用,{{items.quantity}}或项目。任何事情都不会最终显示出来。

any ideas?

有任何想法吗?

When i just test it out like so it works

当我只是测试它时它是有效的

<div ng-repeat="history in orderHistory">
  <div ng-repeat="items in history.orderedItems">
    {{items.product_description}}
  </div>
</div>

but i really need it inside the table

但我真的需要它在桌子里面

I tried the following:

我尝试了以下方法:

    <tbody>
        <tr ng-repeat="history in orderHistory">
            <td>{{history.reference_code}}</td>
            <div ng-repeat="items in history.orderedItems">
                <td>{{items.product_description}}</td>
                <td>{{items.quantity}}</td>
            </div>
            <td>
        </tr>
     </tbody>

and still does not work

仍然无法正常工作

1 个解决方案

#1


5  

UPDATED Answer

更新的答案

http://plnkr.co/edit/x0ZxWSy6JN3fo961NbQX?p=preview

http://plnkr.co/edit/x0ZxWSy6JN3fo961NbQX?p=preview

The following should get you going.

以下内容可以帮到你。

  <table ng-controller="myCtrl">

    <tbody>
      <tr ng-repeat="history in orderHistory">
        <td>{{history.reference_code}}</td>

        <td ng-repeat-start="items in history.orderedItems">
          {{items.product_description}}<//td>

        <td ng-repeat-end>{{items.quantity}}</td>

      </tr>
    </tbody>
  </table>

OLD ANSWER ----- Kept previous answer is kept for historical reasons due to comments. The problem is tbody - not supposed to be repeated. I had a similar problem with <p> just like what you see in here.

旧答案-----由于评论,保留以前的答案是出于历史原因。问题是tbody - 不应该重复。我和

有类似的问题就像你在这里看到的一样。

Here is a fiddle http://jsfiddle.net/yogeshgadge/02y1jjau/1/ where it works - tbody changed to div.

这是一个小提琴http://jsfiddle.net/yogeshgadge/02y1jjau/1/它在哪里工作 - tbody改为div。

Here is one demo where tbody does NOT work http://jsfiddle.net/yogeshgadge/2tk3u7hq/4/

这是一个tbody不起作用的演示http://jsfiddle.net/yogeshgadge/2tk3u7hq/4/

Nested ng-repeat

嵌套的ng-repeat

Try this - moved the ng-repeat on <tr>

试试这个 - 在上移动ng-repeat

<tbody>
        <tr ng-repeat="history in orderHistory">
            <td>{{history.reference_code}}</td>
            <div ng-repeat="items in history.orderedItems">
                <td>{{items.product_description}}</td>
                <td>{{items.quantity}}</td>
            </div>
            <td>
        </tr>
</tbody>

#1


5  

UPDATED Answer

更新的答案

http://plnkr.co/edit/x0ZxWSy6JN3fo961NbQX?p=preview

http://plnkr.co/edit/x0ZxWSy6JN3fo961NbQX?p=preview

The following should get you going.

以下内容可以帮到你。

  <table ng-controller="myCtrl">

    <tbody>
      <tr ng-repeat="history in orderHistory">
        <td>{{history.reference_code}}</td>

        <td ng-repeat-start="items in history.orderedItems">
          {{items.product_description}}<//td>

        <td ng-repeat-end>{{items.quantity}}</td>

      </tr>
    </tbody>
  </table>

OLD ANSWER ----- Kept previous answer is kept for historical reasons due to comments. The problem is tbody - not supposed to be repeated. I had a similar problem with <p> just like what you see in here.

旧答案-----由于评论,保留以前的答案是出于历史原因。问题是tbody - 不应该重复。我和

有类似的问题就像你在这里看到的一样。

Here is a fiddle http://jsfiddle.net/yogeshgadge/02y1jjau/1/ where it works - tbody changed to div.

这是一个小提琴http://jsfiddle.net/yogeshgadge/02y1jjau/1/它在哪里工作 - tbody改为div。

Here is one demo where tbody does NOT work http://jsfiddle.net/yogeshgadge/2tk3u7hq/4/

这是一个tbody不起作用的演示http://jsfiddle.net/yogeshgadge/2tk3u7hq/4/

Nested ng-repeat

嵌套的ng-repeat

Try this - moved the ng-repeat on <tr>

试试这个 - 在上移动ng-repeat

<tbody>
        <tr ng-repeat="history in orderHistory">
            <td>{{history.reference_code}}</td>
            <div ng-repeat="items in history.orderedItems">
                <td>{{items.product_description}}</td>
                <td>{{items.quantity}}</td>
            </div>
            <td>
        </tr>
</tbody>