Angular递归列表中,"list-group"不显示为子列表。
创始人
2024-10-24 12:33:06
0

在Angular递归列表中,如果您希望"list-group"不显示为子列表,可以通过条件判断来控制是否添加"list-group"类。

下面是一个示例代码,展示了如何使用条件判断来解决这个问题:


  • {{ item.name }}
    • No children
// app.component.ts
import { Component } from '@angular/core';

@Component({
  selector: 'app-root',
  template: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  items = [
    {
      name: 'Parent 1',
      children: [
        {
          name: 'Child 1.1',
          children: [
            {
              name: 'Grandchild 1.1.1',
              children: []
            },
            {
              name: 'Grandchild 1.1.2',
              children: []
            }
          ]
        },
        {
          name: 'Child 1.2',
          children: []
        }
      ]
    },
    {
      name: 'Parent 2',
      children: []
    }
  ];
}

在上述示例中,使用了ngIf指令来判断是否添加子列表。如果"item"对象没有子项(children为空数组),则显示"No children"文本,否则递归调用自身(app-recursive-list)来显示子列表。这样可以避免在子列表中添加"list-group"类。

请注意,上述示例只是一种解决方法,实际应用中可能需要根据具体需求进行适当调整。

相关内容

热门资讯

透视了解!hhpoker德州有... 透视了解!hhpoker德州有挂吗,hhpoker德州真的假的(透视)一贯真的是有方法(哔哩哔哩)1...
透视免费!wepoker辅助器... 透视免费!wepoker辅助器官方,微乐四川亲友圈辅助器,普及脚本(有挂解密)-哔哩哔哩1、实时we...
脚本专业!wpk真的有透视嘛,... 脚本专业!wpk真的有透视嘛,wpk辅助插件(透视)真是真的是有挂(哔哩哔哩)1、用户打开应用后不用...
透视辅助!hhpoker是正规... 透视辅助!hhpoker是正规的吗,微信微乐辅助器下载,解迷脚本(有挂秘籍)-哔哩哔哩hhpoker...
透视解密!hhpoker视频巡... 透视解密!hhpoker视频巡查真的假的,hhpoker透视方法(透视)果然是有神器(哔哩哔哩)1、...
透视智能ai!aa poker... 您好,aa poker辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很...
脚本曝光!wepoker的辅助... 脚本曝光!wepoker的辅助器,wepoker黑侠辅助器正版下载(透视)总是存在有软件(哔哩哔哩)...
做出回应!wepoker怎么看... 做出回应!wepoker怎么看牌型,微信小程序游戏破解微乐游戏,辅助脚本(有挂方法)-哔哩哔哩1、玩...
透视推荐!德普之星有透视辅助吗... 透视推荐!德普之星有透视辅助吗,德普之星有辅助软件吗(透视)一直是有app(哔哩哔哩)1、不需要AI...
为了进一步!wpk俱乐部辅助器... 为了进一步!wpk俱乐部辅助器,微乐兰州麻将小程序辅助,详细透视(新版有挂)-哔哩哔哩wpk俱乐部辅...