Skip to content

Instantly share code, notes, and snippets.

@StErMi
Created July 14, 2016 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save StErMi/cda9147c78c725658f114f4202b7047b to your computer and use it in GitHub Desktop.
Save StErMi/cda9147c78c725658f114f4202b7047b to your computer and use it in GitHub Desktop.
Example of loading local JSON data from the Component.js
sap.ui.define([
"sap/ui/core/UIComponent",
"sap/ui/model/json/JSONModel"
], function(UIComponent, JSONModel) {
"use strict";
return UIComponent.extend("com.openui5.example.Component", {
metadata: {
manifest: "json"
},
init: function() {
// call the base component's init function
UIComponent.prototype.init.apply(this, arguments);
//Create the model and load data from the local JSON file
var oModel = new JSONModel("./model/init_data.json");
oModel.setDefaultBindingMode("OneWay");
// set the device model
this.setModel(oModel, "init_data");
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment