mgechev / angularjs-style-guide

📚 Community-driven set of best practices for AngularJS application development

Home Page:https://mgechev.github.io/angularjs-style-guide/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

User Services as your MVC 'Model'

yanivefraim opened this issue · comments

This is an important tip/pattern. Use Services for your MVC's model, As written here:

  1. http://toddmotto.com/rethinking-angular-js-controllers/
  2. http://jonathancreamer.com/the-state-of-angularjs-controllers/
  3. http://slides.com/yanivefraim-1/real-world-angularjs#/20 (slides from my AngularIL presentation)

I will be glad to add a PR for this, if ok by you!

It is already mentioned that you can define your model (not view model) using services. Which is, as well, where you should define your business logic.

You think it needs extra clarification?

I think it is an important point, worth some more explanation. For example, I would add some more details on the controller part, about removing business logic from controller with some explanations why this is so important + it will be cool to add some code example on the service chapter(something similar to what there is in the directory structure chapter, with the 'models' folder:
-models
--Model1.js
--Model1.spec.js

Yeah, I guess the document is not clear enough on this topic, what we have is this and the models folder, which basically comes from nowhere.

PR merged