{"action":"created","issue":{"url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/694","repository_url":"https://api.github.com/repos/johnpapa/angular-styleguide","labels_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/694/labels{/name}","comments_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/694/comments","events_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/694/events","html_url":"https://github.com/johnpapa/angular-styleguide/issues/694","id":142504944,"number":694,"title":"Where to put services that don't have controllers neither views?","user":{"login":"andreshg112","id":15859884,"avatar_url":"https://avatars.githubusercontent.com/u/15859884?v=3","gravatar_id":"","url":"https://api.github.com/users/andreshg112","html_url":"https://github.com/andreshg112","followers_url":"https://api.github.com/users/andreshg112/followers","following_url":"https://api.github.com/users/andreshg112/following{/other_user}","gists_url":"https://api.github.com/users/andreshg112/gists{/gist_id}","starred_url":"https://api.github.com/users/andreshg112/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andreshg112/subscriptions","organizations_url":"https://api.github.com/users/andreshg112/orgs","repos_url":"https://api.github.com/users/andreshg112/repos","events_url":"https://api.github.com/users/andreshg112/events{/privacy}","received_events_url":"https://api.github.com/users/andreshg112/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-21T23:58:18Z","updated_at":"2016-03-22T12:40:02Z","closed_at":"2016-03-22T12:40:02Z","body":"For example: I have a StatesService. It returns all states of a country, but It doesn't have its own view.\r\n1. If It's only used in one view, should I put it into the subfolder of that view?\r\n2. If It's used in many views, where should I put it?\r\n\r\nIn \"Folder-by-feature\" https://github.com/johnpapa/angular-styleguide/tree/master/a1#folders-by-feature-structure, It can see a 'services' folder, but not in image below.\r\n\r\nFor moment, I'm using an \"extra\" folder to put services with no controllers nor views.\r\n\r\n@johnpapa "},"comment":{"url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/comments/199791772","html_url":"https://github.com/johnpapa/angular-styleguide/issues/694#issuecomment-199791772","issue_url":"https://api.github.com/repos/johnpapa/angular-styleguide/issues/694","id":199791772,"user":{"login":"johnpapa","id":1202528,"avatar_url":"https://avatars.githubusercontent.com/u/1202528?v=3","gravatar_id":"","url":"https://api.github.com/users/johnpapa","html_url":"https://github.com/johnpapa","followers_url":"https://api.github.com/users/johnpapa/followers","following_url":"https://api.github.com/users/johnpapa/following{/other_user}","gists_url":"https://api.github.com/users/johnpapa/gists{/gist_id}","starred_url":"https://api.github.com/users/johnpapa/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnpapa/subscriptions","organizations_url":"https://api.github.com/users/johnpapa/orgs","repos_url":"https://api.github.com/users/johnpapa/repos","events_url":"https://api.github.com/users/johnpapa/events{/privacy}","received_events_url":"https://api.github.com/users/johnpapa/received_events","type":"User","site_admin":false},"created_at":"2016-03-22T12:40:02Z","updated_at":"2016-03-22T12:40:02Z","body":"Services don't relate to one View, they relate to a service or set of actions that they help provide for an app. So your scenario is quite common. You're already more than half way there :)\r\n\r\nFirst we decide if we have the need for a service. You already did that with determining it handles state.\r\n\r\nThen we decide how to extract ust that logic. You did that too!\r\n\r\nThen we decide who needs it. Is it used by 1 controller? 1 service? 1 directive? Are they all in 1 feature/module? If used by one module I put it in that module. If used across the app, put it in a shared module.\r\n\r\nGood luck"}}