使用OpenUI5/SAPUI5,根据XML绑定表达式的文档,我们可以从视图中执行函数.
new sap.m.CheckBox({
selected: "{= checkSelectedItems(${odata>CustomerId}) }"
})
Run Code Online (Sandbox Code Playgroud)
在我的控制器后面的视图:
checkSelectedItems: function(sCustomerId) {
return true;
}
Run Code Online (Sandbox Code Playgroud)
在我看来,我得到一般错误,好像它找不到我的函数:
Uncaught TypeError: Cannot read property 'apply' of undefined
Run Code Online (Sandbox Code Playgroud)
我试过用几种方法调用函数:
{= .checkSelectedItems() }
{= my.namespace.checkSelectedItems() }
Run Code Online (Sandbox Code Playgroud)
我甚至尝试在索引页面的脚本标记中添加一个函数,看看它是否只能访问全局函数,但我也无法触发它.建议?我误解了文档吗?
请在这里查看JS Bin:http://jsbin.com/sosotacihi/edit?html,output.我已经注释掉了有问题的CheckBox,但如果你把它放入,你会看到错误.
sapui5 ×1