Skip to content

Commit

Permalink
adding product to cart from product detail page issue Fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ikismail committed Oct 17, 2018
1 parent c3f66df commit bb20d2d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/app/product/product-detail/product-detail.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ <h6 class="my-0">Product Seller</h6>
<span class="text-muted" style="color:crimson !important">{{product.productSeller}}</span>
</li>
</ul>
<button class="btn btn-primary">Add to Cart</button>
<button class="btn btn-primary" (click)="addToCart(product)">Add to Cart</button>
</div>
</div>
</div>
Expand Down Expand Up @@ -55,4 +55,4 @@ <h5 class="product-head">Product Details</h5>
</div>
</div>
</div>
</div>
</div>
6 changes: 5 additions & 1 deletion src/app/product/product-detail/product-detail.component.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Product } from "./../../shared/models/product";
import { Component, OnInit, OnDestroy } from "@angular/core";
import { ActivatedRoute } from "@angular/router";
import { Product } from "../../shared/models/product";
import { ProductService } from "../../shared/services/product.service";
import { LoaderSpinnerService } from "../../shared/loader-spinner/loader-spinner";
import { ToastyService, ToastOptions, ToastyConfig } from "ng2-toasty";
Expand Down Expand Up @@ -56,6 +56,10 @@ export class ProductDetailComponent implements OnInit, OnDestroy {
);
}

addToCart(product: Product) {
this.productService.addToCart(product);
}

ngOnDestroy() {
this.sub.unsubscribe();
}
Expand Down

0 comments on commit bb20d2d

Please sign in to comment.