Add Frontend

This commit is contained in:
2026-01-31 00:09:53 +01:00
parent 325d160a45
commit 7e2e2f1e69
32 changed files with 9466 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { Observable } from 'rxjs';
import { Item } from '../models/item';
@Injectable({
providedIn: 'root'
})
export class ApiService {
private apiUrl = 'http://localhost:8080/api/items';
constructor(private http: HttpClient) { }
getItems(): Observable<Item[]> {
return this.http.get<Item[]>(this.apiUrl);
}
getItem(id: number): Observable<Item> {
return this.http.get<Item>(`${this.apiUrl}/${id}`);
}
createItem(item: Item): Observable<Item> {
return this.http.post<Item>(this.apiUrl, item);
}
updateItem(id: number, item: Item): Observable<Item> {
return this.http.put<Item>(`${this.apiUrl}/${id}`, item);
}
deleteItem(id: number): Observable<any> {
return this.http.delete(`${this.apiUrl}/${id}`);
}
}