SAPUI5 oData V4 读取对象

SAPUI5 oData V4 Read Object

oData V4如何读取UI5中的对象? 基本上我想从 URL 服务获取 JSON 对象: 这是我在控制器中的 onInit 函数。

onInit: function() {
var this_ = this;


this.getView().addEventDelegate({
    onBeforeShow: function(evt) {


        var oModel = new sap.ui.model.json.JSONModel();
        oModel = sap.ui.getCore().getModel("appid");

        var app_id = oModel.getData().app_id;

        this_.getView().bindElement({
            path: "zearnModel>/zearn_summary(" + app_id + ")"
        });

    }
});

}

来自documentation

The OData V4 model only supports data access using bindings. It does not provide any direct access to the data.

要获取原始 JSON 对象,您所能做的就是使用 jQuery's ajax features 请求数据:

$.get({
    url: "<your_service_url>/zearn_summary(" + app_id + ")",
    success: function(data) {
        // your success logic
    },
    error: function(error) {
        // your error logic
    }
});