add safe check for product details

This commit is contained in:
Raghu-Ch
2018-09-17 17:59:31 -04:00
parent 8d3c91bffe
commit 611efa767e
3 changed files with 7 additions and 6 deletions

View File

@@ -1,8 +1,9 @@
<section> <section>
<div class="content"> <div class="content">
<h3>{{product.productName}}</h3> <h3>{{product?.productName}}</h3>
<p>Brand: {{product.brand}}</p> <p>ProductCode: {{product?.productCode}}</p>
<p>$ {{product.price}}</p> <p>Brand: {{product?.brand}}</p>
<p>{{product.category}}</p> <p>Price: ${{product?.price}}</p>
<p>{{product?.category}}</p>
</div> </div>
</section> </section>

View File

@@ -25,7 +25,7 @@ export class ProductDetailComponent implements OnInit {
// console.log(id$); // console.log(id$);
this.productService.getProduct(id).subscribe((res) => { this.productService.getProduct(id).subscribe((res) => {
this.product = res; this.product = res;
console.log(this.product); // console.log(this.product);
}); });
} }
} }

View File

@@ -23,7 +23,7 @@ export class ProductComponent implements OnInit {
this.productService.getProducts().subscribe((res) => { this.productService.getProducts().subscribe((res) => {
this.showSpinner = false; this.showSpinner = false;
this.products = res; this.products = res;
console.log(this.products); // console.log(this.products);
}); });
} }
} }