我的 View 附加了一个模型:
Controller 代码:
var model =
{
title:"Scan RFID container",
question:"Please scan the RFID tag on the container",
answer:"",
type:"input",
options:"",
transaction : ""
};
var oQuestion = new sap.ui.model.json.JSONModel();
oQuestion.setData(model);
this.getView().setModel(oQuestion, "containerChecks");
在我看来,我可以使用大括号来设置文本等。这当然仅适用于解析此内容的 sapui5 元素。
查看代码
this.page = new sap.m.Page({
title: "{containerChecks>/title}",
content: [
new sap.m.Text({
text: "{containerChecks>/question}"
})
],
});
但是我想根据我的模型属性'options'
进行检查。
我尝试过:
var options = this.getModel("containerChecks").getProperty("options");
但是getModel
返回null
最佳答案
当您使用 this.getView().setModel()
在查看中设置模型时如何通过 this.getModel()
访问模型试试这个
var options = this.getView().getModel("containerChecks").getProperty("options");
如果您在 Controller
中使用上述语句.
我确信它可能会给你options
值。
关于javascript - SAPUI5 检查 View 中的模型属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24699514/