简体   繁体   中英

models to a view and component.js in sap ui5

In some of the examples i have seen setting model directly to a view in sap ui5 views(js). what is the actual use of this.

I have seen loading various odata models , assigning to sap.core model and using this odata models in views. what are the uses of using component.js as we can always load a model in view controllers also.

Thanks in advance Prasad

There are 2 questions here and i will answer them

what is the actual use of binding Models to the View?

The View just like HTML DOM is tree structure with various UI controls within them. So if your entire view can consume its data from a model, binding the model to a view makes the data accessible to all controls inside the View through the binding path.

What is the use of Component.js?

Component.js helps you compartmentalize your application as a unit(ie A Component) . That is a component contains all the views in your application and information about their routes and ready to be consumed by another component or a DOM Element. This is just for making your applications modular. Generally your application will have one ODataModel and multiple JSONModels . So instantiation of model can happen in Component since it is the starting point and json models can instantiated in separate views. Again this is not a rule but just a good approach.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM