Last active
August 29, 2019 04:08
-
-
Save mdmoin7/70633123bd75a18051d20f9c6cbb1fc0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<app-product [pData]="pList" (addItem)="saveToCart($event)"></app-product> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, Input, Output, EventEmitter } from '@angular/core'; | |
import { Product } from 'src/app/models/product'; | |
@Component({ | |
selector: 'app-product', | |
template: ` | |
<div> | |
<img [src]="pData.productImage" /> | |
<h3>{{ pData.productName }}</h3> | |
<h4>{{ pData.productPrice }}</h4> | |
<button (click)="addToCart()">Add to Cart</button> | |
</div> | |
`, | |
styleUrls: ['./product.component.css'] | |
}) | |
export class ProductComponent { | |
@Input() pData: Product = null; | |
@Output() addItem=new EventEmitter(); | |
addToCart(){ | |
this.addItem.emit(this.pData); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment