Duration: 14:56 min
Summary: In this lesson, we will see how to create a service using the factory approach. The plan is to create a simple logging service (Angular already has an existing logging service, but here we are creating a new one to illustrate how that can be done). The service will write messages to the console (that you can view using the F12 key). We will be using an existing example that displays the current date/time to call this service. We will start with creating the custom service using angular.module.factory. Then we will refer to the service in the main file and use module dependency. In the custom directive we will reference the service and make calls to the log. By the time we are done, every time we change the format of the date/time in the text box, the information will be written to the log.