0
사용자가 제품을 선택할 수있는 제품을 나열한 체크 박스에 목록을 만들었습니다. 사용자가 선택한 제품의 수량을 변경할 수있는 옵션을 제품 목록에 추가해야합니다. 내가 어떻게 할 수 있니?변경 금액을 추가하고 이오니아의 체크 박스의 합계를 변경하십시오.
내보기 :
<ion-view view-title="Bebidas Adicionais" ng-controller="exBebidasCtrl" >
<div class="bar bar-subheader">
<h2 class="title">{{'Sub-Total R$ ' + getTotalSelected()}}</h2>
</div>
<ion-refresher pulling-text="Puxe para atualizar..." on-refresh="doRefresh()"></ion-refresher>
<ion-list class="card list">
<div class="item item-input">
<i class="icon ion-search placeholder-icon"></i>
<input type="search" ng-model="q" placeholder="Procurar" aria-label="filter bebidasextras" />
</div>
</ion-list>
<ion-list>
<div ng-repeat="bebida in bebidasextras">
<ion-checkbox ng-model="bebida.selected" >
<h2>{{bebida.ad_bebida_titulo}}</h2>
<p>R$ {{bebida.ad_bebida_valor}}</p>
</ion-checkbox>
</div>
</ion-list>
<button class="button button-block button-balanced">
<a ng-click="addToCart(bebida.ad_bebida_titulo,bebida.ad_bebida_valor)" class="button button-assertive button-clear icon ion-android-cart"> Continuar Comprando </a>
</button>
</ion-content>
내 컨트롤러 :
$scope.bebidasextras = [];
var promise = $http.get('http://nhac.esy.es/api_carrinho/lista_bebida_extra.php?json=restaurantes')
.success(function(retorno) {
console.log(retorno);
$scope.bebidasextras = retorno; // não precisa fazer retorno.data
$scope.user = {
bebidasextras: [$scope.bebidasextras[1]]
};
$scope.checkAll = function() {
$scope.user.bebidasextras = angular.copy($scope.bebidasextras);
};
$scope.uncheckAll = function() {
$scope.user.bebidasextras = [];
};
$scope.checkFirst = function() {
$scope.user.bebidasextras = [];
$scope.user.bebidasextras.push($scope.bebidasextras[0]);
};
$scope.setToNull = function() {
$scope.user.bebidasextras = null;
};
$scope.getTotalSelected = function() {
var total = 0;
for(var i = 0; i < $scope.bebidasextras.length; i++){
var bebida = $scope.bebidasextras[i];
total += bebida.selected ? Number(bebida.ad_bebida_valor) : 0;
}
return total;
}
})
.error(function(erro) {
console.log(erro);
});
예, 필요합니다. 그러나, 나는 체크 박스에서 이것을 할 수 없다. – Ramos
왼쪽 및 오른쪽 선택 (확인란)을 사용하여 + 및 - 버튼과 오른쪽으로 정렬 할 수 있습니다. 대부분의 모바일 앱이 제품 수를 처리하는 방식이라고 생각합니다. – Jayesh
나는 마음이 바뀌었다. 나는 그것이 더 나은 것이라고 생각한다. http://stackoverflow.com/questions/38860396/how-create-an-input-box-having-a-and-button-in-ionic – Ramos