[[oktatas:web:angular|< Angular]]
====== Angular táblázat ======
* **Szerző:** Sallai András
* Copyright (c) Sallai András, 2022
* Licenc: [[https://creativecommons.org/licenses/by-sa/4.0/|CC Attribution-Share Alike 4.0 International]]
* Web: https://szit.hu
===== Kiválasztott adatai =====
export interface Product {
"id": number,
"name": string,
"desc": string,
"price": number
}
Termékek
{{ product.name }}
{{ product.desc }}
{{ product.price }} SW
//...
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},
];
constructor() { }
ngOnInit(): void {
}
add_product(product: Product ) {
console.log(product);
}
}
===== Data attribútum =====
Az interfész változatlan:
export interface Product {
"id": number,
"name": string,
"desc": string,
"price": number
}
Termékek
{{ product.name }}
{{ product.desc }}
{{ product.price }} SW
//...
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},
];
constructor() { }
ngOnInit(): void {
}
add_product($event: any) {
console.log($event.target.dataset.id)
}
}