Basic API consumption support and refactored UI to use material (#1)
Co-authored-by: Joe Arndt <jmarndt@users.noreply.github.com> Reviewed-on: #1
This commit is contained in:
parent
bd18fecdff
commit
f2226b2bfd
34 changed files with 726 additions and 55 deletions
24
src/app/services/category.service.ts
Normal file
24
src/app/services/category.service.ts
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { Injectable, signal } from '@angular/core';
|
||||
import { HttpService } from './http.service';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class CategoryService {
|
||||
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) {
|
||||
void this.fetchCategories();
|
||||
}
|
||||
|
||||
public async fetchCategories(): Promise<void> {
|
||||
this.internalCategories.set(await this.http.get<Category[]>(this.categoryPath));
|
||||
}
|
||||
}
|
||||
|
||||
export interface Category {
|
||||
id: string;
|
||||
name: string;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue