Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
Tags
- egov spring ajax 사용 예시
- 아이오닉 스크롤 이벤트
- modal
- mysql if
- 옵저버블
- angular modal
- 모달
- angular button
- ApexChart
- 스크롤 이벤트
- angular animation
- flex-1
- TAILWIND
- 셀렉트박스 커스텀
- 스크롤 이벤트 감지
- 앵귤러 애니메이션
- scroll
- ajax 사용 예시
- Oracle LISTAGG 사용 예시
- Angular Router
- 검색
- Ionic modal
- 호버
- Router
- angular route
- 앵귤러 모달
- formgroup
- route
- prisma
- summary
Archives
- Today
- Total
깜놀하는 해므찌로
ngFor speed controll 반복문 속도 조절 Directive 예시 본문
반응형
SMALL
import { Directive, Input, TemplateRef, ViewContainerRef } from '@angular/core';
@Directive({
selector: '[ngForDelay]'
})
export class NgForDelayDirective {
@Input('ngForDelay') set ngForDelay(value: any[]) {
value.forEach((item: any, index: number) => {
setTimeout(() => {
this.viewContainer.createEmbeddedView(this.templateRef, {
$implicit: item,
index: index
});
}, index * 1000); // 인덱스 * 1초
});
}
constructor(
private templateRef: TemplateRef<any>,
private viewContainer: ViewContainerRef
) {}
}
1. 디렉티브 파일
<ng-container *ngFor="let menu of menus; index as i">
<div
*ngIf="menu.data!['menu']"
[ngForDelay]="menus"
@baseIntroTopAnimation
class="flex font-semibold transition-all cursor-pointer select-none py-7 px-7 active:text-gray-300 active:scale-90 hover:text-gray-300"
(click)="handleMenu(menu)"
[ngClass]="isScrollMoved ? 'text-[#131313]' : 'text-white'"
>
{{ menu.data!['label'] }}
</div>
</ng-container>
2. 템플릿 예시
3. ng-container 를 사용해서 반복문을 돕니다
4. 내부 div 태그에 [ngForDelay] 디렉티브를 사용합니다.
반응형
LIST
'IT' 카테고리의 다른 글
Angular 라우팅 모듈 생성 cli (0) | 2023.05.29 |
---|---|
typescript Utility 유틸리티 활용 예시 / keyof, partial, required, readonly, record, pick, omit, exclude, nonNullAble (0) | 2023.05.28 |
typescript Generic 활용 예시 (0) | 2023.05.27 |
Angular Animation condition 앵귤러 애니메이션 조건 예시 (0) | 2023.05.27 |
Error: Process completed with exit code 1. 배포 에러 해결 (0) | 2023.05.26 |