![]() |
VOOZH | about |
Description of Model is as follows:
Note: Link between Model and View Model is Manipulating Data and between ViewModel and View is 2-way Data Binding.
BASIC INTRODUCTION: [ Way to Structure Code]
FEATURES:
BASIC EXAMPLE: We want to display Name in Purple Color (not written in the proper format, proper length) or Display Purple Color if Age of a person is > 18 years, Display Pink Color if Age of a person is < 18 years, Then the Logic of Purple and Pink Color would be present in ViewModel.
SUMMARY: From Server, Get Data(available in Model Objects), View Model reads Model Objects and then facilitates the easy presentation of data on the view.
The primary differences between MVVM AND MVC are as follows:
| MVVM | MVC |
|---|---|
| The Model is somewhat similar to MVC but here we have ViewModels which are passed to the view and all the logic is in the ViewModel and hence no controller is there. Example: Knockout.js | In this pattern, we have models which are basic objects with no code and just properties, views that contribute to presentation items (HTML, WinForms, etc), client-side deletes, and Controllers that focus on the logic part. Examples: ASP.NET MVC, Angular |
| In MVVM your DeletePerson would be called off of your view model | We have a PersonController with an Action DeletePerson that delete a person |
| We are on the client side so we can hold on to objects and do a lot more logic in a non-disconnected state. | MVC is typically used when things are transactional and disconnected as is the case with server-side web. In ASP MVC we send the view through the wire and then the transaction with the client is over. |
ADVANTAGES:
DISADVANTAGES: