Creating your own services in AngularJS can be confusing. What are the differences between an AngularJS module's Service, Provider and Factory functions? This lesson shows how Angular's service function is just a constructor function.
Thanks for your question Tim. In a production application the module code, service code, and controller code would each be in their own file. I put them together here so that all the code could be seen together on one screen with the thought that it would be easier to understand the code. Note that the code in this example is still being injected in the controller and is decoupled it just is a good practice to keep things in separate files which I am not doing here.