Why is AngularJS considered MV*

时光毁灭记忆、已成空白 提交于 2019-12-23 04:57:35

问题


I have worked with MVC on the back-end (Rails), and am currently working with MVC(MV*) on the front-end (Angular). I have seen Angular as considered an MV* pattern, but why is it considered that exactly?

Using Angular, I understand the separation of concerns, with Views (templates), Controllers, and use Services to serve up data. In this case, the model (data store) via ng-model makes sense for front-end temporary storage, but the actual persistence (when a POST or PUT is made to an API) seems to be the wildcard. As the way data can be persisted, could be handled differently (database, firebase, etc..).

It seems to me that *VC is more appropriate based on my understanding, as Controllers in Angular are better defined than Models.

There must be something core about the MV* pattern that I am missing or confused about, any clarification is greatly appreciated.


回答1:


Here are a few ways * can be chosen in Angular:

  • Controller:

    • ngModelController

    • $controller

  • View Model:

    • dependent expressions

    • directive attributes

  • Presenter:

    • WebGL Directive
  • Presentation-Abstraction-Controller

    • module per iframe

Important thing is that UI and Models are the common denominator. Build interesting UI without breaking app and build interesting business logic without breaking UI.

References

  • Keynote for BackboneConf with Jeremy Ashkenas


来源:https://stackoverflow.com/questions/26165408/why-is-angularjs-considered-mv

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!