|
|
|
|
|
by EdwardMSmith
4908 days ago
|
|
As a person that switched from Backbone to Angular, can you explain models in Angular (from a Backbone standpoint)? I've looked over the docs, and as far as I can tell there really isn't a model in Angular - not anything concrete anyway. The docs seem to explain that any JS object is a model as long as you make some reference to it. Or, is an angular Controller (+ some JS data structure) really a model. Its quite confusing to me. |
|
For example. Within my controller, I set $scope.username to "alex" and this will update any HTML bound to the value "username", within the scope, to "alex". Similarly, I can set, say, $scope.settings = {user: {username: "alex"}} and this will update any HTML elements (within the scope) bound to settings.user.username to "alex".
These are very simple examples, but they show the beauty of having plain JS objects as your "models".