How create an input box having a + and - button in Ionic

Ramos picture Ramos · Aug 9, 2016 · Viewed 13.5k times · Source

How I can create an input box having a + and - button. Clicking upon which user can change the quantity of product selected, like this screen:

input box having a + and - button

Answer

korteee picture korteee · Aug 10, 2016

As for ionic v.1 at your template you could have something like:

<div class="flex_row">
  <button class="button icon ion-minus-circled red" ng-click="sub(item)">
  <p> {{item.quantity}} </p>
  <button class="button icon ion-plus-circled green" ng-click="add(item)">
</div>

At your css

    .red:before {
    color: red;
    }

    .green:before {
    color: green;
    }

    .flex_row {
    display: -webkit-flex;
    display: flex;
    -webkit-flex-direction: row; 
    flex-direction: row;
    }

And in your controller

$scope.sub = function(i) {
  i.quantity--;
}

$scope.add = function(i) {
  i.quantity++;
}