Angularjs remove button not working -
i building shopping app. somewhere in app need show user’s shopping cart , let him edit it. have remove button not working...
<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>
move $scope.remove inside cartcontroller's { }
Comments
Post a Comment