-
Notifications
You must be signed in to change notification settings - Fork 15
ДЗ #3 Параметры для дочерних компонентов и событие добавления в корзину #50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: lecture-3
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Привет!
Все гуд 👍, оставил пару комментариев, буду ждать твоего ответа по ним!
|
||
onProductBuy(event: Event) { | ||
@Output() readonly buyClick: EventEmitter<string> = new EventEmitter<string>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не кажется ли тебе, что получается тавтология?)
...: EventEmitter<string> = new EventEmitter<string>();
Есть ли в этом сакральный смысл?
Мне кажется, что нет, тут отлично сработала бы неявная типизация свойства, а за счет дженерика можно четко указать тип данных передающихся в Output
:
@Output() readonly productBuy = new EventEmitter<string>();
Эта запись мне видится лаконичней, без тавтологии, и не менее типизированной, что важно.
Что думаешь по данному поводу?
@@ -1,13 +1,17 @@ | |||
import {Component} from '@angular/core'; | |||
import {IProduct} from 'src/app/shared/products/product.interface'; | |||
import {productsMock} from 'src/app/shared/products/products.mock'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему использовал абсолютные пути?
|
||
@Component({ | ||
selector: 'app-products-list', | ||
templateUrl: './products-list.component.html', | ||
styleUrls: ['./products-list.component.css'], | ||
}) | ||
export class ProductsListComponent { | ||
onCardClick() { | ||
products: IProduct[] = productsMock; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Я бы тут рекомендовал убрать явную типизацию, т.к. в ней нет особого смысла: она ни читаемости особой не добавляет, ни типизацию не ужесточает, т.к. через механизм неявной типизации - свойство products
сможет отлично унаследовать тип константы productsMock
No description provided.