AngularJS client MVC pattern?

2019-01-12 15:06发布

Until now I was mainly using Struts 2, Spring, JQuery technology stack for building web applications. The point is, that mentioned stack uses server side MVC pattern. The main role of web browsers was limited to a request/response cycle (+ client side validation). Data retrieval, business logic, wiring and validation were mainly responsibilities of the server side.

I have few questions regarding AngularJS framework that were inspired by following quotes I've read:


From the AngularJS tutorial:

For Angular apps, we encourage the use of the Model-View-Controller (MVC) design pattern to decouple the code and to separate concerns.

From the Wikipedia Model–view–controller:

Model–View–Controller (MVC) is an architecture that separates the representation of information from the user's interaction with it. The model consists of application data and business rules, and the controller mediates input, converting it to commands for the model or view


AngularJS uses client side MVC pattern. So I guess there is no other option then to include validation logic also to the client side in some way?

What would be the best way to write a robust AngularJS application? MVC on client side and some kind of MC (model, controller) on server side?

Does that means, that MODEL and CONTROLLER are in one way duplicated (client/server)?

I know my question is somehow weird, but I think the reason is, that I am somehow acustomed to traditional server side MVC pattern. I am sure there is someone, that have already done same transition.

7条回答
Evening l夕情丶
2楼-- · 2019-01-12 15:47

I love what @Roy TrueLove says. But let me say that this is the ultimate way of using angularjs. Of course, you have to learn to do your applications this way, if you want to get the most benefit of angular. I pray to be there some day.

In the meanwhile, during your learning, and during your transition to fully using angularjs as your client side main way of doing things, you can start using it for some small mission here and there, and gradually get accustomed to it and to its way of thinking.

I encourage to gradually embracing it and to go slowly slowly, but surely, I guaranty, sure.

Angularjs is designed to serve this approach, as it can work on the smallest task as good as it can do the biggest one. For example, this first time I used angular was just to show names while the user types ids.

查看更多
登录 后发表回答