In the following code I try to destroy JSON model if it exists:
if(sap.ui.getCore().getModel("modelId")){
console.log(sap.ui.getCore().getModel("modelId"));
sap.ui.getCore().getModel("modelId").destroy();
};
but the above model is not destroyed.
The above model is set in another function and it looks like this:
var oModel = new sap.ui.model.json.JSONModel();
oModel.setData(oData);
sap.ui.getCore().setModel(oModel, "modelId");
console.log(sap.ui.getCore().getModel("modelId"));
The logs are:
the 1st snippet (where I try to destroy the model):
C.extend.constructor {mEventRegistry: Object, oData: Object, bDestroyed: false, aBindings: Array[0], mContexts: Object…}
the second snippet (where the model is set):
EventProvider sap.ui.model.json.JSONModel
What am I missing here? Why the logs are so different?
The main problem in this - is that I try to destroy that model, but it doesn't work.