如何遍历html

时间:2019-09-18 17:42:48

标签: angular angular8

我正在尝试在包含其他Set的Set上使用* ngFor。

<div class="card-deck" *ngFor="let cardDeck of recentlyAdded; let i=index">
                    <div class="card" *ngFor="let documentary of cardDeck">
                        <img [src]="getSantizeUrl(documentary.poster)" class="card-img-top" alt="...">
                        <div class="card-body">
                        <h5 class="card-title">{{ documentary.title }}</h5>
                        <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
                        <p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
                        </div>
                    </div>
                </div>

...

pastebin其他代码https://pastebin.com/AP1Vwa7P

没有控制台错误,只有html源代码中的此错误:

<!--bindings={
  "ng-reflect-ng-for-of": "[object Set]"
}-->

1 个答案:

答案 0 :(得分:1)

要遍历Set,首先必须将其转换为Array,然后循环遍历。

let arrayOfSet= Array.from(pass your set)