In the context of MVC, what is the primary role of the ViewModel?

  • To represent the database model
  • To handle user authentication
  • To manage routing and navigation
  • To pass data from the controller to the view
The primary role of the ViewModel in MVC is to pass data from the controller to the view. It acts as an intermediary between the controller, which retrieves and processes data, and the view, which displays it. This separation helps keep the presentation logic clean and testable.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *