refactored services and expense list
This commit is contained in:
parent
fded7f7c09
commit
6e6cced0c6
15 changed files with 125 additions and 91 deletions
|
|
@ -1,16 +1,22 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Injectable, signal } from '@angular/core';
|
||||
import { HttpService } from './http.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
export class CategoryService {
|
||||
public static readonly CATEGORY_PATH = 'http://localhost:3000/common-cents/categories';
|
||||
private internalCategories = signal<Category[]>([]);
|
||||
public readonly categories = this.internalCategories.asReadonly();
|
||||
public readonly categoryPath = 'http://localhost:3000/common-cents/categories';
|
||||
|
||||
public constructor(private readonly http: HttpService) { }
|
||||
// public categories = signal<Category[]>([]);
|
||||
|
||||
public async getCategories(): Promise<Category[]> {
|
||||
return this.http.get<Category[]>(CategoryService.CATEGORY_PATH);
|
||||
public constructor(private readonly http: HttpService) {
|
||||
void this.fetchCategories();
|
||||
}
|
||||
|
||||
public async fetchCategories(): Promise<void> {
|
||||
this.internalCategories.set(await this.http.get<Category[]>(this.categoryPath));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue