on 02-19-2016 7:11 AM
Hi team,
I have declared two different model in component.js.
One is oDatamodel. I didn't name it.
And another one is a JSON model. its a named model.
The problem is, I am able to bind the unnamed model in all views.
But When I tried to get JSON model, I am getting model is undefined.
The model visibility is not there in other views except in the root view.
For example if I use,
var model = this.getView().getModel("sampleModel"); //named JSON model
in root view, I am getting the object.
But If I use the same in other controller, I am getting undefined error.
Is there any way that I could fix this?
Thanks,
Karthik R
Hi Karthikeyan,
Try something like this in your controller:
var oComponent = this.getOwnerComponent();
var oModel = oComponent.getModel("sampleModel");
Regards,
Sai Vellanki.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Please mark this Discussion with a Correct Answer (closes, but does not lock the Discussion) and Helpful Answer where appropriate. See http://scn.sap.com/community/support/blog/2013/04/03/how-to-close-a-discussion-and-why Even if you discovered the solution without any outside contributions, it helps others to understand what the solution turned out to be.
Do not use Assumed Answered as it confuses anyone looking for the specific answer. If you dig into the Getting Started link (top right of each SCN page), you are only instructed to mark Helpful or Correct Answers to Discussion responses.
Thanks, Mike (Moderator)
SAP Technology RIG
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.