From ca6c0e9b0bd19571f160481c474d6ddba2461853 Mon Sep 17 00:00:00 2001 From: Mikhail Nazyrov Date: Thu, 27 May 2021 17:38:09 +0300 Subject: [PATCH] feat: lessons 2-3 [ref:no-ref] --- .../src/app/shop-card/shop-card.component.ts | 4 ++-- .../src/app/footer/footer.component.html | 2 +- .../src/app/footer/footer.component.ts | 5 ++++- .../product-card/product-card.component.html | 12 ++++++---- .../product-card/product-card.component.ts | 22 +++++++++++++++++-- 5 files changed, 35 insertions(+), 10 deletions(-) diff --git a/1-components/1-shop-card/src/app/shop-card/shop-card.component.ts b/1-components/1-shop-card/src/app/shop-card/shop-card.component.ts index 68a1d20..1f83559 100644 --- a/1-components/1-shop-card/src/app/shop-card/shop-card.component.ts +++ b/1-components/1-shop-card/src/app/shop-card/shop-card.component.ts @@ -17,11 +17,11 @@ export class ShopCardComponent { @Output() public decrement = new EventEmitter(); - public incrementProductInCart() { + public incrementProductInCart(): void { this.increment.emit(); } - public decrementProductInCart() { + public decrementProductInCart(): void { this.decrement.emit(); } } diff --git a/1-components/2-footer/src/app/footer/footer.component.html b/1-components/2-footer/src/app/footer/footer.component.html index 40e7b0d..1069e62 100644 --- a/1-components/2-footer/src/app/footer/footer.component.html +++ b/1-components/2-footer/src/app/footer/footer.component.html @@ -3,7 +3,7 @@ diff --git a/1-components/2-footer/src/app/footer/footer.component.ts b/1-components/2-footer/src/app/footer/footer.component.ts index 07f1064..0ae9f1b 100644 --- a/1-components/2-footer/src/app/footer/footer.component.ts +++ b/1-components/2-footer/src/app/footer/footer.component.ts @@ -1,4 +1,4 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; +import {Component, ChangeDetectionStrategy, Output, Input} from '@angular/core'; @Component({ selector: 'ngx-shop-footer', @@ -7,4 +7,7 @@ import { Component, ChangeDetectionStrategy } from '@angular/core'; }) export class FooterComponent { + public author = 'Angular Course'; + + public currentYear: number = new Date().getFullYear(); } diff --git a/1-components/3-category-product-card/src/app/product-card/product-card.component.html b/1-components/3-category-product-card/src/app/product-card/product-card.component.html index fca87c8..7776748 100644 --- a/1-components/3-category-product-card/src/app/product-card/product-card.component.html +++ b/1-components/3-category-product-card/src/app/product-card/product-card.component.html @@ -1,33 +1,37 @@
-
+

- +{{product?.name}}

+ {{product?.feedbacksCount}} отзыва

- + {{product?.price}}€

-

+

{{product?.price}}€

diff --git a/1-components/3-category-product-card/src/app/product-card/product-card.component.ts b/1-components/3-category-product-card/src/app/product-card/product-card.component.ts index 7f250ba..9894fab 100644 --- a/1-components/3-category-product-card/src/app/product-card/product-card.component.ts +++ b/1-components/3-category-product-card/src/app/product-card/product-card.component.ts @@ -1,8 +1,26 @@ -import { Component, ChangeDetectionStrategy } from '@angular/core'; +import { Component, Input, Output, ChangeDetectionStrategy, EventEmitter } from '@angular/core'; +import { IProduct} from '../../../../../shared/mocks/1-components/product'; @Component({ selector: 'ngx-shop-content-product', templateUrl: './product-card.component.html', changeDetection: ChangeDetectionStrategy.OnPush, }) -export class CategoryProductComponent {} +export class CategoryProductComponent { + @Input() + public product: IProduct = {} as IProduct; + + @Output() + public addToCart = new EventEmitter(); + + @Output() + public goToProduct = new EventEmitter(); + + public addToBasket(): void { + this.addToCart.emit(); + } + + public redirectTo(): void { + this.goToProduct.emit(); + } +}