为什么AngularJS被视为MV * [英] Why is AngularJS considered MV*

查看:115
本文介绍了为什么AngularJS被视为MV *的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在后端(Rails)上使用MVC,目前正在前端(Angular)上使用MVC(MV *).我已经将Angular视为MV *模式,但为什么要这样认为呢?

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?

使用Angular,我了解了关注点的分离,包括视图(模板),控制器和使用服务来提供数据.在这种情况下,通过ng-model的模型(数据存储)对于前端临时存储是有意义的,但是实际的持久性(当对API进行POST或PUT时)似乎是通配符.由于数据的持久存储方式,可以采用不同的方式处理(数据库,firebase等).

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..).

在我看来,根据我的理解,* VC更合适,因为Angular中的Controller比Models更好地定义了.

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

我所缺少或困惑的MV *模式必须有一些核心,对我们的澄清将不胜感激.

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

推荐答案

以下是在Angular中选择*的几种方法:

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

  • 控制器:

  • Controller:

$ controller

查看模型:

指令属性

演示者:

演示文稿抽象控制器

重要的是,UI和模型是共同点.在不破坏应用程序的情况下构建有趣的UI,在不破坏UI的情况下构建有趣的业务逻辑.

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.

参考

这篇关于为什么AngularJS被视为MV *的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆