1. 程式人生 > >Angular購物車的加減

Angular購物車的加減

<td><button ng-click="add($index)">+</button>{{u.num}}<button ng-click="minus($index)">-</button></td>

//加
				$scope.add = function(index){
					$scope.user[index].num++;
				}
				//減
				$scope.minus = function(index){
					if($scope.user[index].num>1){
						$scope.user[index].num--;
					}
					
				}