鑑於

2014-07-11 64 views
0

SAPUI5檢查模型屬性我重視我的看法模型:鑑於

控制器代碼:

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

+0

最後一行'VAR選項= this.getModel ...',在那裏它到底放在哪裏?視圖內部,內部函數內部還是控制器內部? – Qualiture

+0

@Qualiture着createContent – Hazaart

+0

認爲如果是直接在createContent中您的視圖()方法中,然後this.getModel(「containerChecks」)不應該返回null ......您可以發佈JSBin例子嗎? – Qualiture

回答

1

隨着你使用this.getView().setModel()你怎麼可以訪問設置在查看模型通過this.getModel()模型試試這個

var options = this.getView().getModel("containerChecks").getProperty("options"); 

如果您在中使用上述語句。

我相信,它可能給你options值。