When you create a directive, you can put code into the compiler, the link function or the controller.
In the docs, they explain that:
However, for me, it is not clear which kind of code should go where.
E.g.: Can I create functions in compile and have them attached to the scope in link or only attach functions to the scope in the controller?
How are controllers shared between directives, if each directive can have its own controller? Are the controllers really shared or is it just the scope properties?