1

I am attempting to write a service for angular and would like to perform a function inside my service each time I inject it into something else (in this case, to keep track of certain data that will be unique to each controller/service/whatnot that uses the service). I am attempting to run through documentation on angular's injector, but cannot tell if it is actually possible to run a function on injection (or to run something after you've left the scope that you were injected into).

Is this remotely possible? If so, how?

Phil Barresi
  • 1,355
  • 1
  • 14
  • 30
  • 1
    Maybe you need a provider instead of a service: https://groups.google.com/forum/#!msg/angular/56sdORWEoqg/HuZsOsMvKv4J – Christian Bonato Jun 26 '14 at 22:11
  • check the differences between service/factory/provider here: http://stackoverflow.com/questions/15666048/angular-js-service-vs-provider-vs-factory – Kamrul Jun 26 '14 at 22:21

0 Answers0