The ability to reply to discussions is limited to PRO members. Want to join in the discussion? Click here to subscribe now.

Testing a Service

Testing a Service

2:08
Using Jasmine, this lesson will look at testing an AngularJS service.
Watch this lesson now
Avatar
egghead.io

Using Jasmine, this lesson will look at testing an AngularJS service.

Avatar
Bernardo

Hi there. Really appreciate these videos!
Up until now though, I don't think you've explained what we'd use a service for. It looks similar to factories and providers, but I'm not quite sure what canonical/happy-path use case they solve.

Avatar
Paul

Hi Bernardo. Use a service when you want just one of that kind of thing throughout your application. Authentication is a good example of a service...there's only going to be one user logged into the browser that is running an AngularJS application.

A factory, though, can have multiple instances created. Watch the videos about models and you can see some of the examples of how data does and doesn't get shared for services, factories, providers, controllers, etc.

In reply to Bernardo
HEY, QUICK QUESTION!
Joel's Head
Why are we asking?