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 | 29 |
30 |
Tags
- prisma
- mysql if
- 스크롤 이벤트 감지
- ajax 사용 예시
- formgroup
- Ionic modal
- 호버
- 셀렉트박스 커스텀
- egov spring ajax 사용 예시
- 스크롤 이벤트
- Angular Router
- angular route
- summary
- scroll
- ApexChart
- 앵귤러 모달
- 옵저버블
- Oracle LISTAGG 사용 예시
- TAILWIND
- route
- Router
- 모달
- modal
- 검색
- angular button
- angular animation
- 아이오닉 스크롤 이벤트
- flex-1
- 앵귤러 애니메이션
- angular modal
Archives
- Today
- Total
깜놀하는 해므찌로
Angular routerLinkActive menu handle / 앵귤러 라우터 메뉴 핸들 예시 본문
반응형
SMALL
<div
[routerLink]="menu.path"
(click)="handleMenu()"
class="flex items-center justify-between w-56 px-4 py-2 text-gray-400 transition-all duration-300 rounded-md cursor-pointer hover:text-blue-400 hover:bg-blue-50 hover:scale-105"
routerLinkActive="text-gray-700"
>
<div class="flex items-center gap-4">
<app-icon class="w-5 h-5" [name]="menu.data?.['icon']" />
<p class="text-sm"><ng-content></ng-content></p>
</div>
<app-icon
*ngIf="menu.data?.['children']"
class="w-5 h-5 transition-all duration-300"
[ngClass]="{ 'rotate-180': !isOpen }"
[name]="menu.data?.['icon']"
/>
</div>
<div *ngIf="menu.data?.['children'] && isOpen">
<div
*ngFor="let i of menu.data?.['children']"
class="flex items-center gap-4 px-4 py-2 text-gray-400 transition-all duration-300 rounded-md cursor-pointer hover:text-blue-400 hover:bg-blue-50 hover:scale-105"
(click)="handleMenu()"
>
<app-icon class="w-5 h-5" name="mdi:circle-small" />
<p class="text-sm">{{ i.title }}</p>
</div>
</div>
1. 상단 routerLinkActive :현재 라우트 링크와 일치할 경우 명시한 내용을 class name 으로 설정
2. 일반적으로
router.url === menu.path
라는 조건을 활용해서 현재 메뉴와 라우터 url을 비교하기 마련인데, 이 방식을 쓰면 코드도 줄고 더욱 직관적이라 좋습니다.
반응형
LIST
'IT' 카테고리의 다른 글
법정동 스키마 구조 예시 Prisma 시도/시군구 (0) | 2023.08.22 |
---|---|
bash deploy 배포 방법 예시 (0) | 2023.08.21 |
Apexchart toggle custom 아펙스차트 토글 커스텀 예시 (0) | 2023.08.19 |
Prisma foreign key 배열 조회하여 등록하기 예시 / prisma connect (0) | 2023.08.18 |
Ionic Anular nestjs video Upload example / 앵귤러 nestjs 동영상 파일 업로드 예시 feat.AWS S3 (0) | 2023.08.17 |