angular ngfor和ngif指令共用

angular结构指令不能直接嵌套使用,可使用<ng-container>标签来包裹指令

<ul>
<ng-container *ngFor="let item of lists">
<div class="thumb p-date" *ngIf="item.picurl">
<a href="# "><img src="{{item.picurl}} " alt=" " style="width:79px;height: 70px; "></a>
</div>
</ng-container>
</ul>

  

          <li
            nz-submenu
          >
            <span title>Submenu1</span>
            <ul>
              <ng-container *ngFor="let tab1 of tabList;let tabId1 = index">
                <li nz-menu-group
                  [ngClass]="{'ant-menu-item-selected': activeUrl === tab1.url}"
                  (click)="router.navigate([tab1.url])"
                  *ngIf="tabId1 >= 1 && tabId1 <= 4"
                >
                  <span title>{{tab1.name}}</span>
                </li>
              </ng-container>
            </ul>
          </li>

  

posted on 2021-09-29 17:41  左侧岚  阅读(356)  评论(0编辑  收藏  举报

导航