Hari
Hari

Reputation: 297

How to get JSONModel in a controller SAPUI5

I have created a JSON data & saved in webapp/json/TableData.json & in manifest.json, I have added following code : -

"BPCdata" : {
    "type": "sap.ui.model.json.JSONModel",
    "uri": "json/TableData.json"
},

How can I get this model in a controller?.

Upvotes: 0

Views: 3999

Answers (3)

Hari
Hari

Reputation: 297

I have got the model with the following code. It works !!. Thanks for the responses.

var bpcCollect = this.getOwnerComponent().getModel("BPCdata").getProperty("/BPC");

Upvotes: 0

Ashish Patil
Ashish Patil

Reputation: 1742

Pass name of the model to be obtained as argument to getModel()

this.getView().getModel("BPCdata");

Upvotes: 1

Jay
Jay

Reputation: 747

try using sap.ui.getCore().getModel()

Reference : https://sapui5.hana.ondemand.com/#docs/api/symbols/sap.ui.model.Context.html#getModel

Upvotes: 0

Related Questions