[[oktatas:web:angular|< Angular]]
====== Angular táblázat ======
* **Szerző:** Sallai András
* Copyright (c) 2022, Sallai András
* Szerkesztve: 2025
* Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]]
* Web: https://szit.hu
===== Interfész létrehozása =====
ng generate interface product
export interface Product {
id: number,
name: string,
desc: string,
price: number
}
===== Kiválasztott adatai =====
Lista létrehozása, rendelés kiíratása:
export class ProductListComponent implements OnInit {
products: Product[] = [
{"id": 1, "name": "Tej", "desc": "Ovi tej", "price": 2.5},
{"id": 2, "name": "Kenyér", "desc": "fehér 0.5 kg", "price": 2.1},
{"id": 3, "name": "Vaj", "desc": "Ovi vaj", "price": 2.9},
];
orderProduct(product: Product ) {
console.log(product);
}
}
Sablon:
Id |
Name |
Description |
Price |
@for(product of productList; track product.id) {
{{product.id}} |
{{product.name}} |
{{product.desc}} |
{{product.price}} |
|
}