ASP.NET MVC terminology is tripping me up - why 'ViewModel'?

前端 未结 5 491
你的背包
你的背包 2020-12-14 12:45

I\'m an ASP.NET MVC newbie, but have used many Model-View-Controller frameworks previously.

I recently came across the convention of gathering up the pieces of data

5条回答
  •  天涯浪人
    2020-12-14 13:25

    It's called that because it's a "Model made for a View". I understand why the choice of term is a bit confusing.

    It's a helpful approach if you don't want all your data passed to the view as a big hash array. It gives you a strongly-typed class dedicated to the UI, which pollutes neither the core Model or the View. It also allows you to encapsulate UI logic -- views should be kept dumb.

提交回复
热议问题