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

后端 未结 2 739
遥遥无期
遥遥无期 2021-02-09 08:28

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:

2条回答
  •  萌比男神i
    2021-02-09 08:38

    Here's a quickly thrown together example for Ionic 2. If you are using Ionic 1 you should be able to adapt it pretty easily.

    You just need a couple controller/class functions to increment and decrement, then call those on tap from the buttons. This example covers just one button, so something like this wrapped in an ngFor or a

    page.ts:

    private currentNumber = 0;
    constructor () { }
    
    private increment () {
      this.currentNumber++;
    }
    
    private decrement () {
      this.currentNumber--;
    }
    

    page.html:

    
    {{currentNumber}}
    
    

提交回复
热议问题