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
- formgroup
- 앵귤러 모달
- 스크롤 이벤트
- egov spring ajax 사용 예시
- 옵저버블
- flex-1
- Router
- modal
- angular animation
- Angular Router
- 모달
- 아이오닉 스크롤 이벤트
- mysql if
- scroll
- ApexChart
- TAILWIND
- ajax 사용 예시
- 앵귤러 애니메이션
- angular modal
- 셀렉트박스 커스텀
- 스크롤 이벤트 감지
- 호버
- angular route
- 검색
- summary
- Oracle LISTAGG 사용 예시
- angular button
- Ionic modal
- prisma
- route
Archives
- Today
- Total
깜놀하는 해므찌로
Angular route 메뉴 셋팅 예시 본문
반응형
SMALL
import { Route } from '@angular/router';
import { LayoutPage } from './pages/layout/layout.page';
export const appRoutes: Route[] = [
{
path: '',
title: '',
component: LayoutPage,
children: [
{
path: '',
title: ' - 홈',
data: { menu: false },
loadComponent: () =>
import('./pages/index/index.page').then((m) => m.IndexPage),
},
{
path: 'video',
title: ' - 영상',
data: { menu: true, label: '영상', icon: 'assets/icon/video.svg' },
loadComponent: () =>
import('./pages/video/video.page').then((m) => m.VideoPage),
},
{
path: 'marketing',
title: ' - 마케팅',
data: {
menu: true,
label: '마케팅',
icon: 'assets/icon/marketing.svg',
},
loadComponent: () =>
import('./pages/video/video.page').then((m) => m.VideoPage),
},
{
path: 'live_commerce',
title: ' - 라이브커머스',
data: {
menu: true,
label: '라이브커머스',
icon: 'assets/icon/live_commerce.svg',
},
loadComponent: () =>
import('./pages/video/video.page').then((m) => m.VideoPage),
},
{
path: 'ai_solution',
title: ' - AI솔루션',
data: {
menu: true,
label: 'AI솔루션',
icon: 'assets/icon/ai_solution.svg',
},
loadComponent: () =>
import('./pages/video/video.page').then((m) => m.VideoPage),
},
],
},
];
1. 라우트 모듈 내부 구성
2. menu: boolean => 해당 메뉴를 메뉴탭으로 사용할지 여부
import { CommonModule } from '@angular/common';
import { Component, OnInit, HostListener } from '@angular/core';
import { IconComponent } from '../../../components/icon/icon.component';
import { Route, Router } from '@angular/router';
@Component({
selector: 'app-section2',
standalone: true,
templateUrl: './section2.section.html',
styleUrls: ['./section2.section.scss'],
imports: [CommonModule, IconComponent],
})
export class Section2Section implements OnInit {
current: Route | undefined;
menus: Route[] | undefined;
constructor(private readonly router: Router) {
this.menus = router.config[0].children?.filter(
(route) => route.data?.['menu']
);
}
ngOnInit() {}
}
3. Route 파일 참조
<div
*ngFor="let menu of menus; index as i"
class="relative flex basis-1/2 p-1 flex-col items-center text-white/50 hover:bg-primary cursor-pointer hover:text-white hover:scale-[1.2] transition-transform rounded-md opacity-80"
(click)="current = menu"
>
<app-icon class="w-8 h-8" [src]="menu.data!['icon']" />
<div class="flex flex-col items-center gap-3">
<div class="text-sm font-medium">{{menu.path}}</div>
<div class="font-semibold">{{menu.data!['label']}}</div>
</div>
<app-icon
*ngIf="current === menu"
[src]="'assets/image/numbers/' + i + 1 + '.svg'"
class="absolute bottom-0 w-14 h-14"
/>
</div>
4. 템플릿
반응형
LIST
'IT' 카테고리의 다른 글
Tailwind 로딩 화면 spinner (0) | 2023.05.18 |
---|---|
Tailwind active 클릭 하는 시점 효과 / 버튼 효과 (0) | 2023.05.18 |
typescript 가변인자, typescript rest parameter 활용 예시 (0) | 2023.05.18 |
Tailwind 모바일 CSS 배경 이미지 / 늘리거나 깨지지 않고 깔끔하게 배경 채우기 (0) | 2023.05.17 |
tailwind 글씨 자동 줄바꿈 (0) | 2023.05.17 |