我的问题是,在第一个循环之后,函数remove(item,quantity)
无效。代码显示当数量等于zero
时,它会自动{{ 1}}在数组上。
这是我的代码
splice
这是控制器中的功能
<div class="row" ng-repeat="item in items" ng-switch on="$index % 3" >
<div class="col col-33" ng-switch-when="0" >
<div class="row">
<div class="col-30">
<img class="item_image"ng-src="http://WERBSITEISHERE.com/assets/uploads/itemImgs/{{items[$index].img_name}}" alt="" width="100%">
<div class="row menubtn-list nopadding">
<ul style="inline-block">
<li><button class="menubtn-add"ng-click="quantity = quantity+1;addorder(items[$index].item_name,items[$index].price,items[$index].description,quantity,items[$index].id)">+</button>
</li>
<li><span ng-show="quantity > 0">
<button class="menubtn-minus" ng-click="quantity = quantity-1;addorder(items[$index].item_name,items[$index].price,items[$index].description,quantity,items[$index].id);remove(item,quantity)">-</button>
</span>
</li>
</ul>
</div>
</div>
<div class="col-70">
<span>{{items[$index].item_name}}</span><br>
<span>{{items[$index].description}}</span><br>
<span>₱ {{items[$index].price}}</span><br>
<input class="menu-quantity-txtbox" type="number" placeholder="Quantity" ng-model="quantity" disabled>
<!--<div class="row">
<button ng-if="quantity == 0"class="menu-order-btn">Order</button>
<button ng-if="quantity > 0"class="menu-order-btn"ng-click="addorder(items[$index].item_name,items[$index].price,items[$index].description,quantity,items[$index].id)">Order</button>
</div>-->
</div>
</div>
</div>
<div class="col col-33" ng-switch-when="0">
<span ng-show="items[$index+1]">
<div class="row">
<div class="col-30">
<img class="item_image" ng-src="http://WERBSITEISHERE.com/assets/uploads/itemImgs/{{items[$index+1].img_name}}" alt="" width="100%">
<div class="row menubtn-list nopadding">
<ul style="inline-block">
<li><button class="menubtn-add"ng-click="quantity = quantity+1;addorder(items[$index+1].item_name,items[$index+1].price,items[$index+1].description,quantity,items[$index+1].id)">+</button>
</li>
<li><span ng-show="quantity > 0">
<button class="menubtn-minus" ng-click="quantity = quantity-1;addorder(items[$index+1].item_name,items[$index+1].price,items[$index+1].description,quantity,items[$index+1].id);remove(item,quantity)">-</button>
</span>
</li>
</ul>
</div>
</div>
<div class="col-70">
<span>{{items[$index+1].item_name}}</span><br>
<span>{{items[$index+1].description}}</span><br>
<span>₱ {{items[$index+1].price}}</span><br>
<input class="menu-quantity-txtbox" type="number" placeholder="Quantity" ng-model="quantity" disabled>
<!--<div class="row">
<button ng-if="quantity == 0"class="menu-order-btn">Order</button>
<button ng-if="quantity > 0" class="menu-order-btn" ng-click="addorder(items[$index+1].item_name,items[$index+1].price,items[$index+1].description,quantity,items[$index+1].id)">Order</button>
</div>-->
</div>
</div>
<span>
</div>
<div class="col col-33" ng-switch-when="0">
<span ng-show="items[$index+2]">
<div class="row">
<div class="col-30">
<img class="item_image" ng-src="http://WERBSITEISHERE.com/assets/uploads/itemImgs/{{items[$index+2].img_name}}" alt="" width="100%">
<div class="row menubtn-list nopadding">
<ul style="inline-block">
<li><button class="menubtn-add"ng-click="quantity = quantity+1;addorder(items[$index+2].item_name,items[$index+2].price,items[$index+2].description,quantity,items[$index+2].id)">+</button>
</li>
<li><span ng-show="quantity > 0">
<button class="menubtn-minus" ng-click="quantity = quantity-1;addorder(items[$index+2].item_name,items[$index+2].price,items[$index+2].description,quantity,items[$index+2].id);remove(item,quantity)">-</button>
</span>
</li>
</ul>
</div>
</div>
<div class="col-70">
<span>{{items[$index+2].item_name}}</span><br>
<span>{{items[$index+2].description}}</span><br>
<span>₱ {{items[$index+2].price}}</span><br>
<input class="menu-quantity-txtbox" type="number" placeholder="Quantity" ng-model="quantity" disabled>
<!--<div class="row">
<button ng-if="quantity == 0"class="menu-order-btn">Order</button>
<button ng-if="quantity > 0" class="menu-order-btn" ng-click="addorder(items[$index+2].item_name,items[$index+2].price,items[$index+2].description,quantity,items[$index+2].id)">Order</button>
</div>-->
</div>
</div>
<span>
</div>
</div>