Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8644

Re: How to access a value in model.js file from different views

$
0
0

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 do like this include this 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 see these 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.


Viewing all articles
Browse latest Browse all 8644

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>