Skip to Content
-1

How can i Count the no of times a button has Pressed in ui5?

I want to Increase the Value of My input Based on no.of Times a button has Pressed.

How Can i achieve this with simple JS code?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Jan 29 at 01:44 PM

    Hi!

    You can easily manipulate your view throw the model. So minimal structure of your model is {count: 0}.

    View:

    <Input value="{/count}" />
    <Button text="Increase count" press="onIncreaseCountPress" />
    

    Controller:

    onIncreaseCountPress: function() {
        var oModel = //get your model here
        var nCurrentCount = oModel.getProperty('/count');
        oModel.setProperty('/count', ++nCurrentCount);
    }
    
    
    Add comment
    10|10000 characters needed characters exceeded