0
我需要啓用或禁用基於數據長度所以這裏按鈕模型更新是我的XML視圖表達結合不工作時在UI5
<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="{
path: '/listOfData'
}" >
<StandardListItem title="{Name}"/>
</List>
<Button text="AddSomeData" press="onPress" />
</mvc:View>
而在控制器init方法將初始化模型和onPress我加入一些數據模型
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);
}
添加數據後,需要啓用按鈕具有啓用,但它不是發生
任何問題都是綁定或表達式?