← BYTES
AngularJS·Intermediate·Ref: 5.2.1
What is the basic distinction between a controller and a service in AngularJS?
Have a question about this video? Mention reference 5.2.1 when you contact us.
a.They are exactly the same thing with two names
b.A controller is tied to a specific view/scope and is instantiated fresh for each use, while a service is a singleton meant to hold and share logic/data across multiple controllers
c.Services can only store numbers, controllers can store any type
d.Controllers are always asynchronous, services are always synchronous
Controllers are view-specific and recreated whenever their associated element is compiled (e.g. once per ng-repeat item), while services are instantiated once per application (singletons) specifically so that shared state or shared logic can be reused across unrelated controllers without duplication.
Find this on YouTube & Instagram
Every BYTES video is tagged with its reference number and topic — search any of these on YouTube or Instagram to find this one:
#BYTES#BYTES521#AngularJS