title: Where to put model data and behaviour? [tl; dr; Use Services]
body: <p>I am working with AngularJS for my latest project. In the documentation and tutorials all model data is put into the controller scope. I understand that is has to be there to be available for the controller and thus within the corresponding views.</p>
  
  <p>However I dont think the model should actually be implemented there. It might be complex and have private attributes for example. Furthermore one might want to reuse it in another context/app. Putting everything into the controller totally breaks MVC pattern.</p>
  
  <p>The same holds true for the behaviour of any model. If I would use <a href="http://www.artima.com/articles/dci_vision.html" rel="nofollow noreferrer">DCI architecture</a> and separate behaviour from the data model, I would have to introduce additional objects to hold the behaviour. This would be done by introducing roles and contexts.</p>
  
  <p>DCI == <strong>D</strong>ata <strong>C</strong>ollaboration <strong>I</strong>nteraction </p>
  
  <p>Of course model data and behaviour could be implemented with plain javascript objects or any "class" pattern. But what would be the AngularJS way to do it? Using services?</p>
  
  <p><strong>So it comes down to this question:</strong></p>
  
  <p>How do you implement models decoupled from the controller, following AngularJS best practices?</p>