In that sample http calls to server was handled inside controller. That was moved to a custom service provider, viz ‘dataService’, which take care of communication to server.
That custom service was defined using factory method.

Both ‘ContactSearch’ & ‘DetailsController’ controllers depends on ‘dataService’.
A dependency to ‘dataService’ was injected to both controllers and so it can use methods provided by that service.