model
-
September 19, 2022
A view model is a class that allows you to pass data and additional functionality from a place that represents a business logic to a template. It can also provide data loaded from an entity, such as a product.
The View Model class can hold calculation logic, data lookups, and object fetches and passes them directly to a template, so the template’s reasoning can be as simple as possible.
View Models are usually located in the module’s directory called ViewModel. However, the location of view model classes is not limited to a ViewModel guide. You can create as many view models as needed to provide a required set of separate classes with its logic.
Today we’ll learn:
- What is a View Model?
- How to use View Model?