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
- TAILWIND
- route
- 앵귤러 모달
- scroll
- Ionic modal
- 스크롤 이벤트 감지
- 앵귤러 애니메이션
- angular button
- ajax 사용 예시
- 셀렉트박스 커스텀
- 스크롤 이벤트
- flex-1
- angular animation
- 검색
- angular route
- 모달
- angular modal
- summary
- Oracle LISTAGG 사용 예시
- modal
- formgroup
- ApexChart
- Angular Router
- 옵저버블
- 아이오닉 스크롤 이벤트
- 호버
- Router
- prisma
- mysql if
- egov spring ajax 사용 예시
Archives
- Today
- Total
깜놀하는 해므찌로
LocalStorage 활용 예시 / Angular 본문
반응형
SMALL
import { Component, OnInit } from '@angular/core';
import { Admins, Admin } from 'src/lib/admin';
import { CommonModule } from '@angular/common';
import { BadgeComponent } from 'src/app/components/badge/badge.component';
import { ButtonComponent } from 'src/app/components/button/button.component';
import { SearchboxComponent } from 'src/app/components/searchbox/searchbox.component';
import { DateboxComponent } from 'src/app/components/datebox/datebox.component';
import { PageSelectboxComponent } from 'src/app/components/page-selectbox/page-selectbox.component';
import { PaginationComponent } from 'src/app/components/pagination/pagination.component';
import { PageInfo } from 'src/lib/pagination';
import { NgxPaginationModule } from 'ngx-pagination'; // pagination
import { FormsModule } from '@angular/forms';
import { Router } from '@angular/router';
import { ModalController } from '@ionic/angular' // modal
import { ModalPage } from 'src/app/pages/modal/modal.page'; // modal page
@Component({
selector: 'app-admin',
templateUrl: './admin.page.html',
styleUrls: ['./admin.page.scss'],
standalone: true,
imports: [
CommonModule,
BadgeComponent,
ButtonComponent,
SearchboxComponent,
DateboxComponent,
PageSelectboxComponent,
PaginationComponent,
NgxPaginationModule,
FormsModule,
]
})
export class AdminPage implements OnInit {
admins: Admin[] = [];
pageInfo!: PageInfo;
constructor(
private router: Router,
private modalController: ModalController,
) {
if(localStorage.getItem('admins') === 'undefined'){
this.admins = Admins;
}else{
const item = localStorage.getItem('admins');
if(item){
this.admins = JSON.parse(item);
}
}
localStorage.setItem('admins', JSON.stringify(this.admins)); // localStorage
this.pageInfo = { // pagination
itemsCount: this.admins.length,
totalItems: this.admins.length,
itemsPerPage: 10,
totalPages: this.admins.length%10 === 0 ? this.admins.length : this.admins.length + 1,
currentPage: 1,
}
}
ngOnInit() {
this.pageId = 'admin';
this.button = 'bg-blue-950 text-white';
this.placeholder = '공지사항 제목, 내용을 입력해주세요.';
this.iconName = 'heroicons:magnifying-glass-solid';
}
}
}
1. 앵귤러는 localStorage 내장되어 있어 곧바로 "localStorage" 로 사용할 수 있습니다.
반응형
LIST
'IT' 카테고리의 다른 글
C언어 전역변수 활용 예시 (0) | 2023.04.16 |
---|---|
Ionic & component 데이터 이동 예시 on Angular (0) | 2023.04.15 |
Ionic radio 활용 예시 *ngFor (0) | 2023.04.14 |
Angular Router 앵귤러 라우터 작성 방법 (0) | 2023.04.14 |
Angular pagination custom 앵귤러 페이지네이션 커스텀 예시 (0) | 2023.04.13 |