javascriptjsonsapui5jsonmodel

openui5 get Data from JSONModel


I got the problem, that if I set a JSONModel in my controller, I am not able to get the data out of it:

var oModel = new JSONModel(jQuery.sap.getModulePath("QAQuickAccess", "/routes.json"));

this.getView().setModel(oModel);
console.log(oModel.getJSON());

The getJSON method just stringifies the oData object of the model. But it just gives me an empty object. If I only log oModel, I can see the object with its content:

Object content


Solution

  • You can access the properties via oModel.getProperty("/TileCollection");