Hello All,
I have set a json model in Component.js init() method as follows:
var json = {
testValue1: "Hello"
};
var jsonModel = new sap.ui.model.json.JSONModel(json);
that.setModel(jsonModel,"myModel");
I have a view named App.view.xml (and correspodning controller App.controller.js) where I have mapped the model value as follows:
<Input value = "{myModel>/testValue1}" />
At runtime, it works as expected and the input field showed the value "Hello".
Now, I am trying to access this model from view controller (that is from App.controller.js) using the following approaches:
var a = this.OwnerComponent().getModel("myModel");
var b = this.getView().getModel("myModel");
var c = sap.ui.getCore().getModel("myModel");
However, I got the value undefined for the variables a,b and c.
So my question is: How can I access the model which I have set in Component.js from a view controller.
Regards,
Faddy