I need to enable or disable a button based on the bound array size.
<mvc:View
xmlns="sap.m"
xmlns:mvc="sap.ui.core.mvc"
xmlns:core="sap.ui.core"
height="100%"
controllerName="test.controller.expbind">
<Button text="Need to Enable" enabled="{= ${/listOfData}.length > 0 }"/>
<List headerText="Data" items="{/listOfData}">
<StandardListItem title="{Name}" />
</List>
<Button text="AddSomeData" press=".onPress" />
</mvc:View>
onInit: function() {
this.viewModel = new JSONModel({
listOfData: []
});
this.getView().setModel(this.viewModel);
},
onPress: function() {
var existingdata = this.viewModel.getProperty('/listOfData');
existingdata.push({ Name:"New" });
this.viewModel.setProperty('/listOfData', existingdata);
},
After adding the data, the "Need to Enable"-button has to be enabled, but its not happening.
Is there ayny issue with my expression binding?