0
votes

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

1

1 Answers

1
votes

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(i.e. 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.