깜놀하는 해므찌로

Angular *ngIf else 활용 예시 본문

IT

Angular *ngIf else 활용 예시

agnusdei1207 2023. 7. 25. 22:46
반응형
SMALL
<ng-container *ngFor="let dot of [].constructor(8); index as i">
    <img
      src="assets\icon\double_circle.svg"
      class="w-4 h-4"
      *ngIf="i === visibleIndex; else none"
    />
    <ng-template #none>
      <div class="bg-white/50 rounded-full w-1.5 h-1.5"></div>
    </ng-template>
  </ng-container>

1. 일반 if else 와 동일하게 동작합니다.

2. else 변수명 : 사용 시 반드시 <ng-template #변수명> 으로 명시해야 하며, ng-template 태그를 사용해야 합니다.

반응형
LIST