1

i am building a shopping app. Somewhere in the app i need to show the user’s shopping cart and let him edit it. I have remove button but not working...

enter image description here

<html xmlns="http://www.w3.org/1999/xhtml" ng-app>
<head>
<title>Your Shopping Cart</title>
</head>
<body ng-controller="CartController">
<h1>Your Order</h1>
<div ng-repeat="item in items">
    <span>{{item.title}}</span>
    <input ng-model="item.quantity" />
    <span>{{item.price | currency}}</span>
    <span>{{item.price * item.quantity | currency}}</span>
    <button ng-click="remove($index)">Remove</button>
</div>


<script src="js/angular.min.js"></script>
<script>
    function CartController($scope) {
        $scope.items = [
            {title:'Srimad Bhagwat', quantity:8, price:3.95},
            {title:'rupa chintamani', quantity:17, price:12.95},
            {title:'ram charit manas', quantity:5, price:6.95}
        ];
    };

    $scope.remove = function (index) {
        $scope.items.splice(index, 1);
    }
</script>

2
  • What do you mean "not working". Please provide details. What do you want that it does exactly? Commented Jul 17, 2013 at 17:06
  • on click of remove button.. those item should removed. Commented Jul 17, 2013 at 17:11

1 Answer 1

5

Move your $scope.remove inside the CartController's { }

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.