"ShoppingCart-HW"
Bootstrap 3.3.0 Snippet by ReyesJunior

<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <head> <title>Shopping Cart</title> <link rel="stylesheet" type="text/css" href="shoppingcart.css"> <meta name="viewport" content="width=device-width, initial-scale=1"> <!-- Latest compiled and minified CSS --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> </head> <body> <div class="container" ng-app="shoppingCartApp"> <div class="row" ng-controller="ShoppingCartController"> <div class="col-xs-8"> <div class="panel panel-info"> <div class="panel-heading"> <div class="panel-title"> <div class="row"> <div class="col-xs-6"> <h5><span class="glyphicon glyphicon-shopping-cart"></span> {{ title }} </h5> </div> <div class="col-xs-6"> <button type="button" class="btn btn-primary btn-sm btn-block" id="continue-shopping"> <a href="http://bootsnipp.com/snippets/featured/payment-interface"> <span class="glyphicon glyphicon-share-alt"></span> Continue shopping </a> </button> </div> </div> </div> </div> <div class="panel-body"> <div class="row" ng-repeat="product in invoice.products"> <div class="col-xs-2" ng-model="product.image"><img class="img-responsive" ng-src="{{ product.image }}"> </div> <div class="col-xs-4"> <h4 class="product-name" ng-model="product.name"><strong> {{ product.name }} </strong></h4> <h4 class="product-description" ng-model="product.description"><small> {{ product.description }} </small></h4> </div> <div class="col-xs-6"> <div class="col-xs-6 text-right"> <h6 ng-model="product.cost"><strong> {{ product.cost | currency }} <span class="text-muted">x</span></strong></h6> </div> <div class="col-xs-4" > Quantity:<input type="text" class="form-control input-sm" value="1" ng-model="product.quantity"> </div> <div class="col-xs-2"> <button type="button" class="btn btn-link btn-xs" ng-click="removeItem(index)"> <span class="glyphicon glyphicon-trash"> </span> </button> </div> </div> </div> <hr> </div> <div class="panel-footer"> <div class="row text-center"> <div class="col-xs-9"> <h4 class="text-right">Grand Total <strong> {{ grandTotal() | currency }} </strong></h4> </div> <div class="col-xs-3"> <button type="button" class="btn btn-success btn-block"> Checkout </button> </div> </div> </div> </div> </div> </div> </div> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script> <script src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script> <!-- AngularJS --> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.min.js"></script> </body> </html>
body { margin-top: 20px; } #continue-shopping { color: white; }
/* /////////////////////////////////////////////////////////////////////////////////////////////////////////////// */ /* Shopping Cart */ var app = angular.module( 'shoppingCartApp', []); // Route Provider /* Shopping cart Controller */ app.controller( 'ShoppingCartController', [ '$scope', function( $scope ) ] ) { $scope.title = 'Shopping Cart'; $scope.invoice = { products: [ { name = 'Apple', description = 'Yummy Apple', image = 'img.jpg', quantity = 1, cost = '1.35' }, { name = 'Banana', description = 'Yummy Banana', image = 'img.jpg', quantity = 1, cost = '1.75' }, { name = 'Orange', description = 'Yummy Orange', image = 'img.jpg', quantity = 1, cost = '2.55' } ] }; $scope.removeitem = function ( index ) { $scope.invoice.products.splice(index, 1); }, $scope.grandTotal = function () { var total = 0; angular.foreach($scope.invoice.products, function (item) { total += product.quantity * product.cost; }) return total; } }

Related: See More


Questions / Comments: