Created
March 14, 2019 13:23
-
-
Save mdmoin7/5a6417b552629f570d5d8cef20339d2c to your computer and use it in GitHub Desktop.
This file contains hidden or 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, OnInit, Input } from '@angular/core'; | |
import { Product } from '../../models/product'; | |
@Component({ | |
selector: 'app-product', | |
template: `<div> | |
<img [src]="pData.productImage" /> | |
<h3>{{ pData.productName }}</h3> | |
<h4>{{ pData.productPrice }}</h4> | |
<button *ngIf="pData.productStock;else nostock"> | |
Add to Cart | |
</button> | |
<ng-template #nostock> | |
<p>out of stock</p> | |
</ng-template> | |
</div> | |
`, | |
styleUrls: ['./product.component.css'] | |
}) | |
export class ProductComponent { | |
pData: Product = null; | |
constructor() { | |
this.pData={ | |
productId: 1000, | |
productImage: 'some_image.jpg', | |
productName: 'Product 1', | |
productPrice: 10000, | |
productStock: true | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment