我的masterPage中有以下代码:
onInit: function () {
var me = this;
jQuery.ajax({
type: "GET",
contentType: "application/json; charset=utf-8",
url: "RESTAPI",
dataType: "json",
success: function (response, status, xhr) {
debugger;
var oView = me.getView();
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(response);
oView.setModel(oModel);
}
});
me.mBindingOptions = {};
me.oRouter = sap.ui.core.UIComponent.getRouterFor(this);
me.oRouter.getTarget("listainvestimento").attachDisplay(
jQuery.proxy(me.handleRouteMatched, me));
},
_onListItemPress: function (oEvent) {
var context = oEvent.getParameter("listItem").getBindingContext().getPath().substr(1).split("/")[1]
//context="0" (position in my array model)
var oRouter = sap.ui.core.UIComponent.getRouterFor(this);
oRouter.navTo("detalheinvestimento", {
ctx: context
}, false);
}
在我的DetailPage中:
onInit: function () {
this.oRouter = sap.ui.core.UIComponent.getRouterFor(this);
this.oRouter.getTarget("detalheinvestimento").attachDisplay(jQuery.proxy(this.handleRouteMatched, this));
},
handleRouteMatched: function (oEvent) {
this.getView().bindElement({
path: "/" + oEvent.getParameter("arguments").ctx
});
}
Manifest.json
{
"pattern": "listainvestimento/detalheinvestimento/{ctx}",
"name": "detalheinvestimento",
"target": [ "listainvestimento", "detalheinvestimento" ]
},
有关详细信息,我已在Build.me中创建了原型屏幕,并且我现在正在链接到我的实际服务器数据。
master中的绑定成功发生,但非详细。
我不知道错误在哪里,模型是在主设备中设置的,但是当它到达细节时它没有链接。
绑定的字段名称是正确的!
有人能帮助我吗?
答案 0 :(得分:0)
https://blogs.sap.com/2016/10/11/sapui5-load-local-json-model-directly-manifest.json/