Home:ALL Converter>What are models in AngularJS?

What are models in AngularJS?

Ask Time:2014-04-11T11:52:19         Author:Cameron Ball

Json Formatter

I don't really understand what a model is in AngularJS. I know what a model is in the context of an MVC framework. For example in PHP I would create a model, like ApiModel.php or something like that, and in there I would put all sorts of cool stuff for the controller to work with.

This doesn't seem to be the way AngularJS thinks of models, in fact I can't find any good explanation of how to implement a model in AngularJS, but everywhere talks about them.

What is a model in AngularJS and how do I use them in the traditional MVC way?

Author:Cameron Ball,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/23003162/what-are-models-in-angularjs
BKM :

A model in AngularJS specifically communicates with its associated views and controllers and notifies it whether there is a change in its state.\nA more thorough description of what is a model can be found in the following link:\nhttps://web.archive.org/web/20140502052028/http://www.webdeveasy.com/angularjs-data-model/",
2014-04-11T06:48:06
starcodex :

This article is relevant to your inquiry.\n\nMore specifically, he mentions that\n\n\n Model classes encapsulate your application’s data and provide an API to access and manipulate that data. The other classes in your application will make requests of models via this API. When data on the model is updated, the model dispatches events that the other classes within your application can react to. Models are appropriate for capturing the domain logic, such as performing calculations or other manipulations.\n",
2014-04-11T04:16:43
yy