Skip to Content
-1

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

Jan 29 at 01:29 PM

49

avatar image

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?

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Efim Parshin Jan 29 at 01:44 PM
1

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);
}

Show 5 Share
10 |10000 characters needed characters left characters exceeded

While Using getProperty('counter>/count'), getting error: Can't read the getProperty!!!

0
surya prakash tanguturi

You no need to define a name of the model inside "getProperty" method. Just '/count'.

0

Yeah I tried it But Still Same Problem.

Property "/count" does not exist in Element sap.ui.core.mvc.XMLView#orders

0
surya prakash tanguturi

I think you doing something wrong with a model.

Here i made working example:

https://jsbin.com/nuvakaxafu/edit?html,output

1

Yeah Its Helpful.

0