I\'m finding Angular\'s use of models confusing. Angular seems to take the approach that a model can be anything you like - I.E. Angular does not include an explicit model c
Angular does not have an opinion on how you store what you call "model objects". The Angular controller $scope
exists solely as a "view model" for the purposes of managing your UI. I suggest separating these two concepts in your code.
If you want the nicety of Angular scope change notification ($watch
), you can use a scope object to store your model data if you wish (var myScope = $rootScope.$new()
). Just don't use the same scope object to which your UI is bound.
I recommend writing custom services to this end. So the data flow goes like this:
AJAX --> Custom Service --> Model Scope Object --> Controller --> UI Scope Object --> DOM
Or this:
AJAX --> Custom Services --> Plain old JavaScript Objects --> Controller --> UI Scope Object --> DOM