3

So I've been reading/viewing a variety of tutorials about MVC. I am most familiar with building MEAN stack apps, and but am now a little confused on how I thought the MVC worked.

From my understanding in a MEAN stack app the MVC is like: the view is HTML/CSS, the Model is JavaScript(Data and logic of storage objects), and the Controller includes the Controllers, Factories, and Services? (This is where I'm mostly confused). But then I saw a tutorial that explained the whole client side to be the View, the server was the Controller, and the database was the Model.

Does this mean the MVC pattern can be applied to the front and back end of an application? If so, then a MEAN stack app has two MVCs?

Kandianne Pierre
  • 314
  • 1
  • 5
  • 17
  • 1
    Yes, there's two since Angular has its own MVC architecture – OneCricketeer Oct 04 '16 at 02:42
  • @cricket_007 Thanks. Can you also explain how client-side scripting implements the MVC in a MEAN stack app? Is an example how we can inject our Factories and services in a controller? – Kandianne Pierre Oct 04 '16 at 02:47
  • Angular is client side. You mean server side? There isn't really a View on the server – OneCricketeer Oct 04 '16 at 13:24
  • So how could there be two MVCs as you answered then? Do you mean Angular has an MVC and the server side can have an MVC structure, without a view? @cricket_007 – Kandianne Pierre Oct 04 '16 at 17:34
  • I suppose you could say that Express has "Views", but my definition of them falls closer to "Controllers". Mongo doesn't really need "Models", but you can define some, which would be pure JavaScript rather than anything particular to Node.js, Express, or Angular. – OneCricketeer Oct 04 '16 at 17:57
  • As far as Angular is concerned, that has already been answered. http://stackoverflow.com/questions/13067607/angularjs-client-mvc-pattern?rq=1 – OneCricketeer Oct 04 '16 at 17:59

2 Answers2

0

As I understand it, usually the MVC pattern only applied to the front end of an application.

May be this website can help you more : https://evincedev.com/blog/mean-stack-architecture/

xishec
  • 1
  • 1
0

Angular doesn't have MVC architecture. It follows MVVM (Model View ViewModel) architecture. Usually in MVC a database acts as a Model, Server acts as a Controller and front end is the View.

In Angular Controller is replaced by ViewModel. ViewModel acts as a connection between the View and Model. View is written in html files, Model is usually written in Services, ViewModel is written in Controllers.

Srikanth
  • 63
  • 1
  • 5