首页 文章

有意显示空白ng-repeat(对于嵌套数组)

提问于
浏览
0

我正在使用ng-repeat对现有循环的childArray进行迭代(ng-repeat),但我希望在我的孩子ng-repeat上显示空白结果 . 有没有办法做到这一点?我有一个元素结构,我想从孩子ng-repeat中显示出来 .

代码如下所示:

<ng-repeat="row in parentArray"> <--- the parent array
{{row.name}}
{{row.date}}
{{row.place}}

    <ng-repeat="option in row"> <--- the child array
    Result : {{option.name}} <-- I still want result to show up

</ng-repeat>
</ng-repeat>

1 回答

  • 2

    如果我理解正确的话,如果没有选择,你想展示一些东西吗?

    ng-repeat 仅适用于数据 . 没有数据时,不显示任何内容 . 为此,您可以使用 ng-ifng-show / ng-hide

    此外,我目前还不清楚选项存储在行中的位置

    HTML

    <ng-repeat="row in parentArray"> <--- the parent array
    {{row.name}}
    {{row.date}}
    {{row.place}}
    
    
        <div ng-if="row.options.length > 0">
            <ng-repeat="option in row.options"> <--- the child array
            Result : {{option.name}} <-- I still want result to show up
        </div>
        <div ng-if="row.options.length === 0">
           <label>No Data</label>
        </div>
    
    </ng-repeat>
    

相关问题