nan error
This commit is contained in:
BIN
src/app/pages/category/._category.component.ts
Normal file
BIN
src/app/pages/category/._category.component.ts
Normal file
Binary file not shown.
BIN
src/app/pages/category/._subcategories.component.ts
Normal file
BIN
src/app/pages/category/._subcategories.component.ts
Normal file
Binary file not shown.
@@ -40,7 +40,17 @@ export class CategoryComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.routeSubscription = this.route.params.subscribe(params => {
|
this.routeSubscription = this.route.params.subscribe(params => {
|
||||||
const id = parseInt(params['id'], 10);
|
const id = Number.parseInt(params['id'], 10);
|
||||||
|
|
||||||
|
if (!Number.isFinite(id) || id <= 0) {
|
||||||
|
this.error.set('Invalid category ID');
|
||||||
|
this.items.set([]);
|
||||||
|
this.hasMore.set(false);
|
||||||
|
this.loading.set(false);
|
||||||
|
this.isLoadingMore = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.categoryID.set(id);
|
this.categoryID.set(id);
|
||||||
this.resetAndLoad();
|
this.resetAndLoad();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -41,7 +41,18 @@ export class SubcategoriesComponent implements OnInit, OnDestroy {
|
|||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.routeSubscription = this.route.params.subscribe(params => {
|
this.routeSubscription = this.route.params.subscribe(params => {
|
||||||
const id = parseInt(params['id'], 10);
|
const id = Number.parseInt(params['id'], 10);
|
||||||
|
|
||||||
|
if (!Number.isFinite(id) || id <= 0) {
|
||||||
|
this.error.set('Invalid category ID');
|
||||||
|
this.categories.set([]);
|
||||||
|
this.subcategories.set([]);
|
||||||
|
this.nestedSubcategories.set([]);
|
||||||
|
this.categoryItems.set([]);
|
||||||
|
this.loading.set(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.loadForParent(id);
|
this.loadForParent(id);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user