on 08-19-2015 2:30 AM
Hi experts,
i have a doubt that i have maintained a model.js file and having two views and two controllers.Now i have an object i.e., it contains set of arrays in model.js.Now i want to access this array in 2nd view's controller.js file.Can any one clarify my doubt?
Thanks to all
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Suneel,
I'm not sure whether I understood the requirement properly or not. But, what I understood is
You're have a separate file in project structure named as model.js - Something like below:
var oModel = {
Labels: {
Header: {
CodeLabel: "CompanyCode",
ClientLabel: "Client",
SLLabel: "StorageLocation",
WCLabel: "WorkCenter",
MATNRLabel: "Material",
RQLabel: "RequiredQuantity"
}
}
}
You wanted to access the above file in second view.
If this was the requirement, you can include the above file in your html script like below -
<script src="Model.js" type="text/javascript"></script> // Make sure you are giving the correct path in src attribute
You can fetch this model in two different ways.
1. You can just do oModel.Labels.Header.CodeLabel , where you will get "CompanyCode" value.
2. As Sergio suggested, you can bind this model to your view and you can access the model by providing correct path. Consider you wanted to bind CompanyCode to your Label control, then you could do -
new sap.m.Label({text:"{/oModel/Labels/Header/CodeLabel}"});
(or)
new sap.m.Label().bindProperty("text", "/oModel/Labels/Header/CodeLabel");
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.
you should assign the model to a view... the model can have one or more arrays / objects (read on named model) then from your view you could read the data from any of the endpoints in the model by using the correct path.
so if your model contains something like:
{
array1: SomeArray,
array2: anotherarray,
arrayN: anotherNArray
}
then you should be able to read ... path: /arrray1, or /array2, or /arrayN
hope this helps
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
89 | |
10 | |
9 | |
9 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.