Browse Source
adding to cart is working fine and flushing details to db is not implemented yet
gauravAngular
adding to cart is working fine and flushing details to db is not implemented yet
gauravAngular
7 changed files with 192 additions and 62 deletions
Split View
Diff Options
-
39Angular-UrbanBazaar/src/app/components/cart/cart.component.css
-
80Angular-UrbanBazaar/src/app/components/cart/cart.component.html
-
18Angular-UrbanBazaar/src/app/components/cart/cart.component.ts
-
24Angular-UrbanBazaar/src/app/components/home/home.component.html
-
21Angular-UrbanBazaar/src/app/components/home/home.component.ts
-
64Angular-UrbanBazaar/src/app/services/cart.service.ts
-
8Angular-UrbanBazaar/src/app/services/product.service.ts
@ -0,0 +1,39 @@ |
|||
.card |
|||
{ |
|||
height: 60vh; |
|||
margin: 25px; |
|||
padding: 25px; |
|||
} |
|||
|
|||
.center{ |
|||
position: absolute; |
|||
top: 50%; |
|||
left: 50%; |
|||
transform: translate(-50%,-50%); |
|||
text-align: center; |
|||
} |
|||
h4,h6{ |
|||
font-weight: 400; |
|||
} |
|||
.shopNow{ |
|||
padding: 5%; |
|||
background-color: rgb(79 79 243); |
|||
color: aliceblue; |
|||
border-radius: 15px; |
|||
border-color: white; |
|||
} |
|||
.card-table{ |
|||
position: relative; |
|||
display: flex; |
|||
flex-direction: column; |
|||
align-items: center; |
|||
|
|||
} |
|||
/* .center .btn{ |
|||
font-size: 14px !important; |
|||
margin-top: 20px !important; |
|||
font-weight: 400; |
|||
padding: 12px 72px; |
|||
border-radius: 3px !important; |
|||
|
|||
} */ |
|||
@ -1,32 +1,52 @@ |
|||
<!-- <p>cart works!</p> --> |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||
<title>Document</title> |
|||
</head> |
|||
<body> |
|||
|
|||
<table border="2px"> |
|||
<tr > |
|||
<td>productid</td> |
|||
<td>productname</td> |
|||
<td>productprice</td> |
|||
<td>productweight</td> |
|||
</tr> |
|||
|
|||
<tr *ngFor="let c of cartdetails | async"> |
|||
<td>{{c.productname}}</td> |
|||
<td>{{c.productprice}}</td> |
|||
<td>{{c.productweight}}</td> |
|||
</tr> |
|||
<ng-container *ngIf="cartdetails.length !=0"> |
|||
<div class="container"> |
|||
<div class="card-table"> |
|||
<div class="card-product"> |
|||
<div class="table tabe-responsive"> |
|||
<thead> |
|||
<tr> |
|||
<th>S.No</th> |
|||
<th>ProductName</th> |
|||
<th>ProductPrice</th> |
|||
|
|||
<th>Action</th> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<tr *ngFor="let c of cartdetails; let i = index"> |
|||
<td>{{i+1}}</td> |
|||
<td>{{c.productname}}</td> |
|||
<td>{{c.productprice}}</td> |
|||
<td> |
|||
<button class="deleteButton" (click)="removeItem(c)">Delete</button> |
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan="4"></td> |
|||
<td><button (click)=emptyCart()>Empty Cart</button></td> |
|||
<td><button routerLink='/'>Shop More</button></td> |
|||
<td><button>Checkout</button></td> |
|||
<td><strong>Grand Total : Rs.{{grandTotal}}</strong></td> |
|||
</tr> |
|||
</tbody> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</div> |
|||
</ng-container> |
|||
|
|||
<ng-container *ngIf="cartdetails.length==0"> |
|||
<div class="container"> |
|||
<div class="card"> |
|||
<h5 class="card-title">My Cart</h5> |
|||
</div> |
|||
|
|||
|
|||
|
|||
</table> |
|||
|
|||
</body> |
|||
</html> |
|||
<div class="center"> |
|||
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcT9q9U7YaUc27iaqP1bbyD3g6GSLqlRmAFbeQ&usqp=CAU" |
|||
alt=""> |
|||
<h4>Your cart is empty!</h4> |
|||
<h6>Add item to it now</h6> |
|||
<button class="shopNow" routerLink='/'>Shop Now</button> |
|||
</div> |
|||
</div> |
|||
</ng-container> |
|||
@ -1,32 +1,16 @@ |
|||
<!-- <p>home works!</p> --> |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
|
|||
<head> |
|||
<meta charset="UTF-8"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> |
|||
<title>Document</title> |
|||
</head> |
|||
|
|||
<body> |
|||
<div> |
|||
<button class="showButton" (click)="showButton()">ShowCart</button> |
|||
|
|||
</div> |
|||
|
|||
|
|||
<div class="cardParent"> |
|||
<div class="card" *ngFor="let i of products|async"> |
|||
<div class="card" *ngFor="let i of products"> |
|||
<img src="{{i.productimage}}" style="width:100%"> |
|||
<h6>{{i.productname}}</h6> |
|||
<p class="price">Rs.{{i.productprice}}</p> |
|||
<p class="price">Weight {{i.productweight}}</p> |
|||
<p><button class="Addbutton" (click)="addCart()">Add to Cart</button></p> |
|||
<p><button class="Addbutton" (click)=addCart(i)>Add to Cart</button></p> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
|
|||
</body> |
|||
|
|||
</html> |
|||
</div> |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue