Yeah, the directive documentation doesn't mention anything about returning a function.
But, this $compile documention does say:
Comprehensive Directive API
There are many different options for a directive.
The difference resides in the return value of the factory function. You can either return a "Directive Definition Object" (see below) that defines the directive properties, or just the postLink
function (all other properties will have the default values).
And there is an example below (see the comment at the bottom).
var myModule = angular.module(...);
myModule.directive('directiveName', function factory(injectables) {
var directiveDefinitionObject = {
link: function postLink(scope, iElement, iAttrs) { ... }
};
return directiveDefinitionObject;
// or
// return function postLink(scope, iElement, iAttrs) { ... }
});