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 | 31 |
Tags
- angular route
- modal
- angular button
- 앵귤러 애니메이션
- TAILWIND
- flex-1
- scroll
- angular modal
- Ionic modal
- route
- mysql if
- Router
- ApexChart
- Oracle LISTAGG 사용 예시
- 아이오닉 스크롤 이벤트
- 앵귤러 모달
- 옵저버블
- summary
- 모달
- formgroup
- 호버
- 셀렉트박스 커스텀
- Angular Router
- angular animation
- ajax 사용 예시
- prisma
- 검색
- 스크롤 이벤트
- egov spring ajax 사용 예시
- 스크롤 이벤트 감지
Archives
- Today
- Total
깜놀하는 해므찌로
Angular typescript 검색 기능 예시 ts / Date 날짜 비교 본문
반응형
SMALL
searchCondition(): void {
this.items = this.orderService.getItem();
// 탭
if (this.currentTab !== '전체') {
this.items = this.items.filter(
(_item) => _item.state === this.currentTab
);
}
// 카테고리
if (this.currentBranch !== '지점') {
this.items = this.items.filter(
(_item) => _item.branchName === this.currentBranch
);
}
// 날짜
if (this.startAt && this.endAt) {
this.items = this.items.filter((_item) => {
return (
dayjs(_item.createdAt).isAfter(dayjs(this.startAt)) &&
dayjs(_item.createdAt).isBefore(dayjs(this.endAt))
);
});
} else if (this.startAt && !this.endAt) {
this.items = this.items.filter((_item) => {
return dayjs(_item.createdAt).isAfter(dayjs(this.startAt));
});
} else if (!this.startAt && this.endAt) {
this.items = this.items.filter((_item) => {
return dayjs(_item.createdAt).isBefore(dayjs(this.endAt));
});
}
// 검색어
if (this.searchKeyword) {
this.items = this.items.filter((_item) => {
return (
_item.ordererName.includes(this.searchKeyword) ||
_item.product.includes(this.searchKeyword)
);
});
}
this.setPage();
}
1. filter 함수 사용시 {} 중괄호를 표기하여 안에 로직을 작성할 경우 반드시 boolean 값을 return 하라고 명시해야 합니다.
반응형
LIST
'IT' 카테고리의 다른 글
전화번호 정규식 자동 '-' hyphen 처리 (0) | 2023.04.17 |
---|---|
dayJs (0) | 2023.04.17 |
C언어 전역변수 활용 예시 (0) | 2023.04.16 |
Ionic & component 데이터 이동 예시 on Angular (0) | 2023.04.15 |
LocalStorage 활용 예시 / Angular (0) | 2023.04.14 |