In this blog post I’ll introduce you the new way of annotating services included in AngularAOP v0.1.0.
First, why we need a new way for annotation? In v0.0.1 the annotations were made in services’ bodies. It was something like this:
This way of annotating services led to coupling between the services and the API of the AngularAOP’s aspect factory service called execute. By this coupling we weren’t able to reuse our services in new projects which don’t use AngularAOP.
v0.1.0 introduces a brand new way of annotation which doesn’t couple your services with AngularAOP at all! Now you can declaratively annotate your services in the config callback of your module. For the annotations is used object literal:
As you see in AwesomeService you don’t have any dependencies which couples you with AngularAOP! Awesome, right? Internally AngularAOP uses $provide.decorator to decorate your target services. May be the only drawback from this approach is that you must define your services as providers because otherwise AngularAOP won’t be able to use them in the config callback, in order to decorate them.