23 lines
702 B
TypeScript
23 lines
702 B
TypeScript
import { Component, inject, signal } from "@angular/core";
|
|
import { ProductCard } from "./components/product-card/product-card";
|
|
import { HttpClient } from "@angular/common/http";
|
|
import { API_URL } from "../../core/tokens/api-url-tokens";
|
|
import { ProductModel } from "../../core/models/product.model";
|
|
import { ProductService } from "./services/product-service";
|
|
|
|
@Component({
|
|
selector: "app-products",
|
|
imports: [ProductCard],
|
|
templateUrl: "./product.html",
|
|
})
|
|
export class Product {
|
|
productService = inject(ProductService);
|
|
products = signal<ProductModel[]>([]);
|
|
|
|
ngOnInit() {
|
|
this.productService.getProducts().subscribe((data) => {
|
|
this.products.set(data.data);
|
|
});
|
|
}
|
|
}
|